From ceacad79e68e1d22b9726cb5bb86f158b7100a01 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 26 Sep 2012 12:42:41 +0530 Subject: [PATCH] profile.py - do not allow rename of Administrator, Guest and on rename, change user in __Auth table --- py/core/doctype/profile/profile.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/py/core/doctype/profile/profile.py b/py/core/doctype/profile/profile.py index 22eb622172..e9a77cbfff 100644 --- a/py/core/doctype/profile/profile.py +++ b/py/core/doctype/profile/profile.py @@ -193,6 +193,11 @@ Thank you,
sendmail_md(self.doc.email, subject="Welcome to " + startup.product_name, msg=txt % args) def on_rename(self,newdn,olddn): + # do not allow renaming administrator and guest + if olddn in ["Administrator", "Guest"]: + webnotes.msgprint("""Hey! You are restricted from renaming the user: %s""" % \ + (olddn, ), raise_exception=1) + tables = webnotes.conn.sql("show tables") for tab in tables: desc = webnotes.conn.sql("desc `%s`" % tab[0], as_dict=1) @@ -205,9 +210,14 @@ Thank you,
update `%s` set `%s`=%s where `%s`=%s""" % \ (tab[0], field, '%s', field, '%s'), (newdn, olddn)) + + # set email webnotes.conn.sql("""\ update `tabProfile` set email=%s where name=%s""", (newdn, newdn)) + + # update __Auth table + webnotes.conn.sql("""update __Auth set user=%s where user=%s""", (newdn, olddn)) @webnotes.whitelist() def get_all_roles(arg=None):