fix: no role assigned message when role profile is passed (#21342)

* Fix: no role assigned message when role profile is passed

* refactor: rename misleading method

---------

Co-authored-by: Ankush Menat <ankush@frappe.io>
This commit is contained in:
Vishal Kumar 2023-06-13 11:10:47 +05:30 committed by GitHub
parent db358aafd5
commit 9d20509492
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -28,6 +28,7 @@ from frappe.utils import (
now_datetime,
today,
)
from frappe.utils.deprecations import deprecated
from frappe.utils.password import check_password, get_password_reset_limit
from frappe.utils.password import update_password as _update_password
from frappe.utils.user import get_system_managers
@ -75,6 +76,7 @@ class User(Document):
self.validate_email_type(self.email)
self.validate_email_type(self.name)
self.add_system_manager_role()
self.populate_role_profile_roles()
self.check_roles_added()
self.set_system_user()
self.set_full_name()
@ -85,7 +87,6 @@ class User(Document):
self.remove_disabled_roles()
self.validate_user_email_inbox()
ask_pass_update()
self.validate_roles()
self.validate_allowed_modules()
self.validate_user_image()
self.set_time_zone()
@ -98,12 +99,16 @@ class User(Document):
):
self.set_social_login_userid("frappe", frappe.generate_hash(length=39))
def validate_roles(self):
def populate_role_profile_roles(self):
if self.role_profile_name:
role_profile = frappe.get_doc("Role Profile", self.role_profile_name)
self.set("roles", [])
self.append_roles(*[role.role for role in role_profile.roles])
@deprecated
def validate_roles(self):
self.populate_role_profile_roles()
def validate_allowed_modules(self):
if self.module_profile:
module_profile = frappe.get_doc("Module Profile", self.module_profile)