Skip to content

Commit

Permalink
fix: create raven user for website users if role is assigned to them
Browse files Browse the repository at this point in the history
  • Loading branch information
nikkothari22 committed Feb 23, 2024
1 parent 3c5ff79 commit de4d009
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions raven/raven/doctype/raven_user/raven_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,11 @@ def add_user_to_raven(doc,method):
raven_user.enabled = 0
raven_user.save(ignore_permissions=True)
else:
# Raven user does not exist. Check if the user is a system user.
if doc.user_type == "System User":
# Only create raven user if it exists in the system.
if frappe.db.exists("User", doc.name):
# Raven user does not exist.
# Only create raven user if it exists in the system.
if frappe.db.exists("User", doc.name):
# Check if the user is a system user.
if doc.user_type == "System User":
auto_add = frappe.db.get_single_value("Raven Settings", "auto_add_system_users")

if auto_add:
Expand All @@ -103,12 +104,12 @@ def add_user_to_raven(doc,method):
raven_user.full_name = doc.first_name
raven_user.enabled = 1
raven_user.insert(ignore_permissions=True)
else:
if "Raven User" in [d.role for d in doc.get("roles")]:
# Create a Raven User record for the user.
raven_user = frappe.new_doc("Raven User")
raven_user.user = doc.name
if not doc.full_name:
raven_user.full_name = doc.first_name
raven_user.enabled = 1
raven_user.insert(ignore_permissions=True)
else:
if "Raven User" in [d.role for d in doc.get("roles")]:
# Create a Raven User record for the user.
raven_user = frappe.new_doc("Raven User")
raven_user.user = doc.name
if not doc.full_name:
raven_user.full_name = doc.first_name
raven_user.enabled = 1
raven_user.insert(ignore_permissions=True)

0 comments on commit de4d009

Please sign in to comment.