fix: Clear active sessions when user type changes (#37402)
Users often need to log out and log back in when session type changes. This PR just does it for them. Co-authored-by: AarDG10 <aarol.dsouza@gmail.com>
This commit is contained in:
parent
657b1eb50c
commit
c3781f1bd7
1 changed files with 3 additions and 9 deletions
|
|
@ -393,6 +393,9 @@ class User(Document):
|
|||
"""Set as System User if any of the given roles has desk_access"""
|
||||
self.user_type = "System User" if self.has_desk_access() else "Website User"
|
||||
|
||||
if self.has_value_changed("user_type"):
|
||||
clear_sessions(user=self.name, force=True)
|
||||
|
||||
def set_roles_and_modules_based_on_user_type(self):
|
||||
user_type_doc = frappe.get_cached_doc("User Type", self.user_type)
|
||||
if user_type_doc.role:
|
||||
|
|
@ -427,15 +430,6 @@ class User(Document):
|
|||
self.doctype, self.name, self.name, write=1, share=1, flags={"ignore_share_permission": True}
|
||||
)
|
||||
|
||||
def validate_share(self, docshare):
|
||||
pass
|
||||
# if docshare.user == self.name:
|
||||
# if self.user_type=="System User":
|
||||
# if docshare.share != 1:
|
||||
# frappe.throw(_("Sorry! User should have complete access to their own record."))
|
||||
# else:
|
||||
# frappe.throw(_("Sorry! Sharing with Website User is prohibited."))
|
||||
|
||||
def send_password_notification(self, new_password):
|
||||
try:
|
||||
if self.flags.in_insert:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue