-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #375 from frappe/develop
chore: Merge develop to main
- Loading branch information
Showing
3 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import frappe | ||
from frappe import _ | ||
from frappe.auth import LoginManager | ||
|
||
|
||
@frappe.whitelist(allow_guest=True) | ||
def login(): | ||
if not frappe.conf.demo_username or not frappe.conf.demo_password: | ||
return | ||
frappe.local.response["redirect_to"] = "/crm" | ||
login_manager = LoginManager() | ||
login_manager.authenticate(frappe.conf.demo_username, frappe.conf.demo_password) | ||
login_manager.post_login() | ||
frappe.local.response["type"] = "redirect" | ||
frappe.local.response["location"] = frappe.local.response["redirect_to"] | ||
|
||
|
||
def validate_reset_password(user): | ||
if frappe.conf.demo_username and frappe.session.user == frappe.conf.demo_username: | ||
frappe.throw( | ||
_("Password cannot be reset by Demo User {}").format( | ||
frappe.bold(frappe.conf.demo_username) | ||
), | ||
frappe.PermissionError, | ||
) | ||
|
||
|
||
def validate_user(doc, event): | ||
if frappe.conf.demo_username and frappe.session.user == frappe.conf.demo_username and doc.new_password: | ||
frappe.throw( | ||
_("Password cannot be reset by Demo User {}").format( | ||
frappe.bold(frappe.conf.demo_username) | ||
), | ||
frappe.PermissionError, | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# import frappe | ||
from frappe import _ | ||
from frappe.core.doctype.user.user import User | ||
from crm.api.demo import validate_reset_password | ||
|
||
|
||
class CustomUser(User): | ||
def validate_reset_password(self): | ||
# restrict demo user to reset password | ||
validate_reset_password(self) |