コード例 #1
0
ファイル: install.py プロジェクト: bindscha/wnframework_old
def after_install():
	# reset installed apps for re-install
	webnotes.conn.set_global("installed_apps", '["webnotes"]')
	
	# core users / roles
	install_docs = [
		{'doctype':'Profile', 'name':'Administrator', 'first_name':'Administrator', 
			'email':'admin@localhost', 'enabled':1},
		{'doctype':'Profile', 'name':'Guest', 'first_name':'Guest',
			'email':'guest@localhost', 'enabled':1},
		{'doctype':'UserRole', 'parent': 'Administrator', 'role': 'Administrator', 
			'parenttype':'Profile', 'parentfield':'user_roles'},
		{'doctype':'UserRole', 'parent': 'Guest', 'role': 'Guest', 
			'parenttype':'Profile', 'parentfield':'user_roles'},
		{'doctype': "Role", "role_name": "Report Manager"}
	]
	
	for d in install_docs:
		try:
			webnotes.bean(d).insert()
		except NameError:
			pass

	# all roles to admin
	webnotes.bean("Profile", "Administrator").get_controller().add_roles(*webnotes.conn.sql_list("""
		select name from tabRole"""))

	# update admin password
	from webnotes.auth import _update_password
	_update_password("Administrator", webnotes.conf.get("admin_password"))

	webnotes.conn.commit()
コード例 #2
0
def update_profile_name(args):
	if args.get("email"):
		args['name'] = args.get("email")
		webnotes.flags.mute_emails = True
		webnotes.bean({
			"doctype":"Profile",
			"email": args.get("email"),
			"first_name": args.get("first_name"),
			"last_name": args.get("last_name"),
			"profile_type":"Employee"
		}).insert()
		webnotes.flags.mute_emails = False
		from webnotes.auth import _update_password
		_update_password(args.get("email"), args.get("password"))

	else:
		args['name'] = webnotes.session.user

		# Update Profile
		if not args.get('last_name') or args.get('last_name')=='None': 
				args['last_name'] = None
		webnotes.conn.sql("""update `tabProfile` SET first_name=%(first_name)s,
			last_name=%(last_name)s WHERE name=%(name)s""", args)
		
	if args.get("attach_profile"):
		filename, filetype, content = args.get("attach_profile").split(",")
		fileurl = save_file(filename, content, "Profile", args.get("name"), decode=True).file_name
		webnotes.conn.set_value("Profile", args.get("name"), "user_image", fileurl)
		
	add_all_roles_to(args.get("name"))
コード例 #3
0
ファイル: profile.py プロジェクト: saurabh6790/OFF-RISLIB
	def validate(self):
		# webnotes.errprint("TEST")
		self.in_insert = self.doc.fields.get("__islocal")
		if self.doc.name not in ('Guest','Administrator','SuAdmin') and self.doc.email:
			self.validate_email_type(self.doc.email)
		self.validate_max_users()
		self.add_system_manager_role()
		self.check_enable_disable()
		if self.in_insert:
			if self.doc.name not in ("Guest", "Administrator", "SuAdmin") and (self.doc.email or self.doc.number) and cint(self.doc.mute_email)!=1:
				self.send_welcome_mail()
				webnotes.msgprint(_("Welcome Message Sent"))
			if cint(self.doc.mute_email) == 1 and self.doc.name not in ("Guest", "Administrator", "SuAdmin"):
				webnotes.conn.sql("insert into __Auth values ('%s', password('%s'))"%(self.doc.name, 'password'))
				webnotes.conn.sql("commit")
		else:
			if cint(self.doc.mute_email)!=1:
				self.email_new_password()
			if cint(self.doc.mute_email)==1 and self.doc.name not in ("Guest", "Administrator", "SuAdmin") and self.doc.new_password:
				webnotes.conn.sql("""update __Auth set password=password('%s') where user='******'"""%(self.doc.new_password, self.doc.name),debug=1)
				webnotes.conn.sql("commit")
			if cint(self.doc.mute_email)==1 and self.doc.name in ("Guest", "Administrator", "SuAdmin") and self.doc.new_password:
				from webnotes.auth import _update_password
				_update_password(self.doc.name, self.doc.new_password)
		self.doc.new_password = ""
コード例 #4
0
	def email_new_password(self):
		if self.doc.new_password and not self.in_insert:
			from webnotes.auth import _update_password
			_update_password(self.doc.name, self.doc.new_password)

			self.password_update_mail(self.doc.new_password)
			webnotes.msgprint("New Password Emailed.")
コード例 #5
0
ファイル: profile.py プロジェクト: saurabh6790/alert-med-lib
	def email_new_password(self):
		if self.doc.new_password and not self.in_insert:
			from webnotes.auth import _update_password
			_update_password(self.doc.name, self.doc.new_password)

			self.password_update_mail(self.doc.new_password)
			webnotes.msgprint("New Password Emailed.")
コード例 #6
0
ファイル: setup_wizard.py プロジェクト: Tejal011089/med2-app
def update_profile_name(args):
    if args.get("email"):
        args['name'] = args.get("email")
        webnotes.flags.mute_emails = True
        webnotes.bean({
            "doctype": "Profile",
            "email": args.get("email"),
            "first_name": args.get("first_name"),
            "last_name": args.get("last_name")
        }).insert()
        webnotes.flags.mute_emails = False
        from webnotes.auth import _update_password
        _update_password(args.get("email"), args.get("password"))

    else:
        args['name'] = webnotes.session.user

        # Update Profile
        if not args.get('last_name') or args.get('last_name') == 'None':
            args['last_name'] = None
        webnotes.conn.sql(
            """update `tabProfile` SET first_name=%(first_name)s,
			last_name=%(last_name)s WHERE name=%(name)s""", args)

    if args.get("attach_profile"):
        filename, filetype, content = args.get("attach_profile").split(",")
        fileurl = save_file(filename,
                            content,
                            "Profile",
                            args.get("name"),
                            decode=True).file_name
        webnotes.conn.set_value("Profile", args.get("name"), "user_image",
                                fileurl)

    add_all_roles_to(args.get("name"))
コード例 #7
0
def make_demo_user():
	from webnotes.auth import _update_password
	
	roles = ["Accounts Manager", "Analytics", "Expense Approver", "Accounts User", 
		"Leave Approver", "Blogger", "Customer", "Sales Manager", "Employee", "Support Manager", 
		"HR Manager", "HR User", "Maintenance Manager", "Maintenance User", "Material Manager", 
		"Material Master Manager", "Material User", "Manufacturing Manager", 
		"Manufacturing User", "Projects User", "Purchase Manager", "Purchase Master Manager", 
		"Purchase User", "Quality Manager", "Report Manager", "Sales Master Manager", 
		"Sales User", "Supplier", "Support Team"]
		
	def add_roles(bean):
		for role in roles:
			p.doclist.append({
				"doctype": "UserRole",
				"parentfield": "user_roles",
				"role": role
			})
	
	# make demo user
	if webnotes.conn.exists("Profile", "*****@*****.**"):
		webnotes.delete_doc("Profile", "*****@*****.**")

	p = webnotes.new_bean("Profile")
	p.doc.email = "*****@*****.**"
	p.doc.first_name = "Demo"
	p.doc.last_name = "User"
	p.doc.enabled = 1
	p.doc.user_type = "ERPNino Demo"
	p.insert()
	add_roles(p)
	p.save()
	_update_password("*****@*****.**", "demo")
	
	# make system manager user
	if webnotes.conn.exists("Profile", "*****@*****.**"):
		webnotes.delete_doc("Profile", "*****@*****.**")
	
	p = webnotes.new_bean("Profile")
	p.doc.email = "*****@*****.**"
	p.doc.first_name = "Admin"
	p.doc.last_name = "User"
	p.doc.enabled = 1
	p.doc.user_type = "System User"
	p.insert()
	roles.append("System Manager")
	add_roles(p)
	p.save()
	_update_password("*****@*****.**", "admin010123")
	
	# only read for newsletter
	webnotes.conn.sql("""update `tabDocPerm` set `write`=0, `create`=0, `cancel`=0
		where parent='Newsletter'""")
	webnotes.conn.sql("""update `tabDocPerm` set `write`=0, `create`=0, `cancel`=0
		where parent='Profile' and role='All'""")
	
	webnotes.conn.commit()
コード例 #8
0
    def update_new_password(self):
        """update new password if set"""
        if self.doc.new_password:
            from webnotes.auth import _update_password
            _update_password(self.doc.name, self.doc.new_password)

            if self.in_insert:
                webnotes.msgprint("New user created. - %s" % self.doc.name)
                if cint(self.doc.send_invite_email):
                    self.send_welcome_mail(self.doc.new_password)
                    webnotes.msgprint("Sent welcome mail.")
            else:
                self.password_update_mail(self.doc.new_password)
                webnotes.msgprint("New Password Emailed.")

            webnotes.conn.set(self.doc, 'new_password', '')
コード例 #9
0
ファイル: profile.py プロジェクト: Yellowen/wnframework
	def update_new_password(self):
		"""update new password if set"""
		if self.doc.new_password:
			from webnotes.auth import _update_password
			_update_password(self.doc.name, self.doc.new_password)
			
			if self.in_insert:
				webnotes.msgprint("New user created. - %s" % self.doc.name)
				if cint(self.doc.send_invite_email):
					self.send_welcome_mail(self.doc.new_password)
					webnotes.msgprint("Sent welcome mail.")
			else:
				self.password_update_mail(self.doc.new_password)
				webnotes.msgprint("New Password Emailed.")
				
			webnotes.conn.set(self.doc, 'new_password', '')
コード例 #10
0
ファイル: profile.py プロジェクト: bindscha/wnframework_old
def update_password(new_password, key=None, old_password=None):
	# verify old password
	if key:
		user = webnotes.conn.get_value("Profile", {"reset_password_key":key})
		if not user:
			return _("Cannot Update: Incorrect / Expired Link.")
	elif old_password:
		user = webnotes.session.user
		if not webnotes.conn.sql("""select user from __Auth where password=password(%s) 
			and user=%s""", (old_password, user)):
			return _("Cannot Update: Incorrect Password")
	
	_update_password(user, new_password)
	
	webnotes.conn.set_value("Profile", user, "reset_password_key", "")
	
	return _("Password Updated")
コード例 #11
0
def update_password(new_password, key=None, old_password=None):
	# verify old password
	if key:
		user = webnotes.conn.get_value("Profile", {"reset_password_key":key})
		if not user:
			return _("Cannot Update: Incorrect / Expired Link.")
	elif old_password:
		user = webnotes.session.user
		if not webnotes.conn.sql("""select user from __Auth where password=password(%s) 
			and user=%s""", (old_password, user)):
			return _("Cannot Update: Incorrect Password")
	
	from webnotes.auth import _update_password
	_update_password(user, new_password)
	
	webnotes.conn.set_value("Profile", user, "reset_password_key", "")
	
	return _("Password Updated")
コード例 #12
0
ファイル: profile.py プロジェクト: bindscha/wnframework_old
	def validate(self):
		self.in_insert = self.doc.fields.get("__islocal")
		if self.doc.name not in ('Guest','Administrator'):
			self.validate_email_type(self.doc.email)
		self.validate_max_users()
		self.add_system_manager_role()
		self.check_enable_disable()
		if self.in_insert:
			if self.doc.name not in ("Guest", "Administrator"):
				if self.doc.new_password:
					# new password given, no email required
					_update_password(self.doc.name, self.doc.new_password)
				if not getattr(self, "no_welcome_mail", False):
					self.send_welcome_mail()
					msgprint(_("Welcome Email Sent"))
		else:
			try:
				self.email_new_password()
			except webnotes.OutgoingEmailError:
				pass # email server not set, don't send email
				
		self.doc.new_password = ""
コード例 #13
0
 def validate(self):
     # webnotes.errprint("TEST")
     self.in_insert = self.doc.fields.get("__islocal")
     if self.doc.name not in ('Guest', 'Administrator',
                              'SuAdmin') and self.doc.email:
         self.validate_email_type(self.doc.email)
     self.validate_max_users()
     self.add_system_manager_role()
     self.check_enable_disable()
     if self.in_insert:
         if self.doc.name not in ("Guest", "Administrator", "SuAdmin") and (
                 self.doc.email
                 or self.doc.number) and cint(self.doc.mute_email) != 1:
             self.send_welcome_mail()
             webnotes.msgprint(_("Welcome Message Sent"))
         if cint(self.doc.mute_email) == 1 and self.doc.name not in (
                 "Guest", "Administrator", "SuAdmin"):
             webnotes.conn.sql(
                 "insert into __Auth values ('%s', password('%s'))" %
                 (self.doc.name, 'password'))
             webnotes.conn.sql("commit")
     else:
         if cint(self.doc.mute_email) != 1:
             self.email_new_password()
         if cint(self.doc.mute_email) == 1 and self.doc.name not in (
                 "Guest", "Administrator",
                 "SuAdmin") and self.doc.new_password:
             webnotes.conn.sql(
                 """update __Auth set password=password('%s') where user='******'"""
                 % (self.doc.new_password, self.doc.name),
                 debug=1)
             webnotes.conn.sql("commit")
         if cint(self.doc.mute_email) == 1 and self.doc.name in (
                 "Guest", "Administrator",
                 "SuAdmin") and self.doc.new_password:
             from webnotes.auth import _update_password
             _update_password(self.doc.name, self.doc.new_password)
     self.doc.new_password = ""
コード例 #14
0
def make_demo_user():
    from webnotes.auth import _update_password

    roles = [
        "Accounts Manager", "Analytics", "Expense Approver", "Accounts User",
        "Leave Approver", "Blogger", "Customer", "Sales Manager", "Employee",
        "Support Manager", "HR Manager", "HR User", "Maintenance Manager",
        "Maintenance User", "Material Manager", "Material Master Manager",
        "Material User", "Manufacturing Manager", "Manufacturing User",
        "Projects User", "Purchase Manager", "Purchase Master Manager",
        "Purchase User", "Quality Manager", "Report Manager",
        "Sales Master Manager", "Sales User", "Supplier", "Support Team"
    ]

    def add_roles(bean):
        for role in roles:
            p.doclist.append({
                "doctype": "UserRole",
                "parentfield": "user_roles",
                "role": role
            })

    # make demo user
    if webnotes.conn.exists("Profile", "*****@*****.**"):
        webnotes.delete_doc("Profile", "*****@*****.**")

    p = webnotes.new_bean("Profile")
    p.doc.email = "*****@*****.**"
    p.doc.first_name = "Demo"
    p.doc.last_name = "User"
    p.doc.enabled = 1
    p.doc.user_type = "ERPNext Demo"
    p.insert()
    add_roles(p)
    p.save()
    _update_password("*****@*****.**", "demo")

    # make system manager user
    if webnotes.conn.exists("Profile", "*****@*****.**"):
        webnotes.delete_doc("Profile", "*****@*****.**")

    p = webnotes.new_bean("Profile")
    p.doc.email = "*****@*****.**"
    p.doc.first_name = "Admin"
    p.doc.last_name = "User"
    p.doc.enabled = 1
    p.doc.user_type = "System User"
    p.insert()
    roles.append("System Manager")
    add_roles(p)
    p.save()
    _update_password("*****@*****.**", "admin010123")

    # only read for newsletter
    webnotes.conn.sql(
        """update `tabDocPerm` set `write`=0, `create`=0, `cancel`=0
		where parent='Newsletter'""")
    webnotes.conn.sql(
        """update `tabDocPerm` set `write`=0, `create`=0, `cancel`=0
		where parent='Profile' and role='All'""")

    webnotes.conn.commit()
コード例 #15
0
ファイル: install.py プロジェクト: ricardomomm/wnframework
	def update_admin_password(self, password):
		from webnotes.auth import _update_password
		webnotes.conn.begin()
		_update_password("Administrator", webnotes.conf.get("admin_password") or password)
		webnotes.conn.commit()
コード例 #16
0
    def update_admin_password(self, password):
        from webnotes.auth import _update_password

        webnotes.conn.begin()
        _update_password("Administrator", getattr(conf, "admin_password", password))
        webnotes.conn.commit()
コード例 #17
0
 def update_admin_password(self, password):
     from webnotes.auth import _update_password
     webnotes.conn.begin()
     _update_password("Administrator",
                      webnotes.conf.get("admin_password") or password)
     webnotes.conn.commit()