Commit graph

19 commits

Author SHA1 Message Date
Shrihari Mahabal
7e45db4cec fix: invalidate user invitation if already accepted 2026-04-29 19:20:47 +05:30
Aarol D'Souza
0122b49ef6
Merge pull request #37554 from AarDG10/refactor-password
refactor(user): misc. fixes and refactors
2026-04-09 11:26:33 +05:30
Safwan Samsudeen
8fe9996e30 fix: allow setting chunk size from site settings 2026-03-10 13:03:07 +05:30
AarDG10
6885bf8a64 refactor: return link only when used internally
Restrict _reset_password() for internal use. Return link when used as an internal func, whitelisted method to be used otherwise, when resetting password.

Co-authored-by: Ankush Menat <ankushmenat@gmail.com>
2026-03-09 12:08:08 +05:30
Ritvik Sardana
35e0a18007 chore: code cleanup 2026-02-26 15:08:12 +05:30
Ritvik Sardana
bd32237fa5 fix: use hooks to get allowed fields in the API 2026-02-26 13:43:32 +05:30
Ritvik Sardana
c23d188fbf fix: add **args param to add invite with app specific fields 2026-02-26 12:51:07 +05:30
Elton Lobo
86e38ecade
fix: invitation user relation (#33603)
* fix(user-invitation): unlink user from invitations on delete

* fix(user-invitation): disallow inviting disabled users

* style(user-invitation): format code

* test(user-invitation): correct tests after invitation user relation fix

* test(user-invitation): add invite by email api's disabled user test

* docs(user-invitation): mention disabled users processing

* refactor(user-invitation): add `User invitation` doctype to `ignore_links_on_delete`

* Revert "refactor(user-invitation): add `User invitation` doctype to `ignore_links_on_delete`"

This reverts commit a70e4800c8182ea562b28a65239c82e1bed5e612.
2025-08-14 16:26:23 +05:30
Elton Lobo
6d1008933f
feat: add user invitation doctype & related public methods (#33308)
* feat: add user invitation doctype & related public methods

* style(user-invitation): execute formatters & add semgrep comments

* refactor(user-invitation): use `is` to compare `None` values

* fix(user-invitation): skip fetching `after_accept` for default app

* fix(user-invitation): translate email templates

* fix(user-invitaton): return pending invites from invite by email api

* refactor(user-invitation): improve code quality

* fix(user-invitation): translate all error messages

* refactor(user-invitation): improve security & readability

Improvements:
- move invite expiration check to `daily_maintenance`
- explicitly import all of the used packages
- specify methods for all security-critical endpoints
- improve error messages and give them suitable titles
- remove unnecessary utility functions
- make invitation key management secure
- translate all of the subjects of the sent emails
- use the `app_title` hook to create email titles
- commit the work done after each iteration of the background invitation
  expiry checker
- restructure code to improve readability
- use `user.reset_password` to generate the target link
- use clear long names to name identifiers
- add document states with relevant colors (User Invitation doctype)
- differ `sendmail` emails whenever possible
- send an email to the invitation creator instead of the invitee after
  the invite has expired
- remove `User Invitation Manager` role

* fix(user-invitation): use valid emails to test doctype & related code

* feat(user-invitation): support adding multiple roles

* refactor(user-invitation): mark relevant fields `set only once`

* feat(user-invitation): add `Cancelled` status

* test(user-invitation): correct broken tests

* test(user-invitation): form valid f-strings & run code formatter

* feat(user-invitation): make doctype usable from desk

* fix(user-invitation): remove delete permission from invitation doctype

* feat(user-invitation): pass user inserted info to `after_accept` hook

* refactor(user-invitation): improve custom action methods & errors

Improvements:
- trigger actions only when the invitation is in the `Pending` state
- use lowercase letters to start error messages
- handle cases where `user_invitation_hook` is not defined

* refactor(user-invitation): remove site name from email templates

* docs(user-invitation): add internal documentation

* feat(user-invitation): add 'get pending' & cancel invites apis

* fix(user-invitation): make invitation app specific

* refactor(user-invitation): avoid mixing function programming

* fix(user-invitation): make apis usable for app specific valid users

* fix(user-invitation): allow app specific invites

* feat(user-invitation): make list view & permission checks app specific

* refactor(user-invitation): convert class methods to static when possible

* feat(user-invitation): add `app_only_for` method to the doc

* fix(user-invitation): f-string syntax error in `get_permission_query_conditions`

* docs(user-invitation): add examples & improve the internal doc

* refactor: rename method name

static_ is unnecessary
only_for doesn't make sense in this context when arguments are not roles

* fix: Support POST request too

We dont follow REST semantics 100%, anything that modifies something
should ideally be doable with POST too.

* chore: cap

* fix: Avoid ignore_permissions as user arg

---------

Co-authored-by: Ankush Menat <ankush@frappe.io>
2025-07-28 16:25:53 +05:30
Ankush Menat
071e269548 fix!: Switch to creation as default sort order 2024-03-27 11:18:28 +05:30
Hussain Nagaria
8d2137c265 docs: consistent doc strings 2023-12-18 18:27:39 +05:30
Ankush Menat
c55dcc439e
feat: max_file_size configurable from system settings (#22384)
also increase default max_file_size from 10MB to 25MB
2023-09-13 13:33:36 +05:30
Raffael Meyer
6ea739e4cf
refactor(File): explicitly import utils (#22143) 2023-08-23 11:08:22 +05:30
Ankush Menat
4d048cd651 fix: type hint for image view
closes https://github.com/frappe/frappe/issues/19426
2023-01-02 11:50:25 +05:30
Gavin D'souza
029a1fc902 chore: Remove loose types from fn definitions 2022-12-15 13:47:05 +05:30
Gavin D'souza
2327a56abc fix(File): Correct acceptable types in APIs
- Allow str types for start, page_length in page_length API
- Allow str, list[dict] file_list in move_file API
2022-12-15 13:47:05 +05:30
Ankush Menat
81b37cb7d2
refactor: clean up code to py310 supported features (#17367)
refactor: clean up code to py39+ supported syntax

- f-strings instead of format
- latest typing support instead of pre 3.9 TitleCase
- remove UTF-8 declarations.
- many more changes

Powered by https://github.com/asottile/pyupgrade/ + manual cleanups
2022-07-01 11:51:05 +05:30
Gavin D'souza
8db6bf48f6 fix(linting): Sort imports 2022-04-18 18:17:40 +05:30
Gavin D'souza
59e45a2e2f refactor: File APIs
Restructured and moved most APIs under frappe.core.api.file namespace.
Changed some obvious security gaps (like using get_list instead of
get_all for an endpoint), styled, added type hints and made minor performance
enhancements.

Changes
* download_file API
    * Move API to handler.py
    * Check for permissions via File.is_downloadable instead
* Moved APIs to new namespace: `frappe.core.api.file`
* Backwards compatibility
    * Added APIs to override_whitelisted_methods to maintain existing
      client endpoints
    * Imported APIs to controller's namespace to avoid breaking external
      app usages
2022-03-15 19:39:47 +05:30