当前位置: 首页>>代码示例>>Python>>正文


Python User.passwordHash方法代码示例

本文整理汇总了Python中model.User.passwordHash方法的典型用法代码示例。如果您正苦于以下问题:Python User.passwordHash方法的具体用法?Python User.passwordHash怎么用?Python User.passwordHash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在model.User的用法示例。


在下文中一共展示了User.passwordHash方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import passwordHash [as 别名]
	def post(self):
		self.session[LOGIN_NEXT_PAGE_KEY] = self.URL
		roles=Role.all()
		if roles.count() == 0:
			# No roles were set up, set them up now
			adminRole = Role()
			adminRole.name=ROLE_ADMIN
			adminRole.put()
			role = Role()
			role.name=ROLE_DELIVERY_GUY
			role.put()
			role = Role()
			role.name=ROLE_COOK
			role.put()
			role = Role()
			role.name=ROLE_AGENT
			role.put()
			user = User()
			user.email = self.request.get("adminEmail")
			user.password = "[email protected]#"
			m = hashlib.md5()
			encodedString = self.request.get("adminPassword").encode('ascii', errors='replace')
			m.update(encodedString)
			user.passwordHash = str(m.hexdigest())
			user.activated = True
			user.role = adminRole
			user.put();
			template = jinja_environment.get_template('templates/setup/setupSuccess.html')
			self.printPage("Sikeres inicializálás", template.render(), True, True)
		else:
			template = jinja_environment.get_template('templates/setup/alreadySetUp.html')
			self.printPage("Korábban inicializálva", template.render(), True, True)
开发者ID:lajthabalazs,项目名称:diet-futar,代码行数:34,代码来源:siteAdmin.py

示例2: post

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import passwordHash [as 别名]
	def post(self):
		referer = None
		refererKey = self.request.get('refererKey')
		if refererKey != None and refererKey != "":
			referer = User.get(refererKey)
		email = self.request.get('email')
		phoneNumber = self.request.get('phoneNumber')
		password = self.request.get('password')
		passwordCheck = self.request.get('passwordCheck')
		familyName= self.request.get('familyName')
		givenName= self.request.get('givenName')
		sourceOfInfo=self.request.get('sourceOfInfo')
		user = {}
		user["email"]= email
		user["familyName"]=familyName
		user["givenName"]=givenName
		user["phoneNumber"]=phoneNumber
		user["sourceOfInfo"]=sourceOfInfo
		users = User.gql('WHERE email = :1', email)
		refererUrlPart = ""
		if referer != None:
			refererUrlPart = "?refererKey=" + str(referer.key())
		self.session[USER]=user
		if (users.count(1)>0):
			self.session[REGISTRATION_ERROR_KEY]=REGISTRATION_ERROR_EXISTING_USER
			self.redirect('/registration' + refererUrlPart)
		elif (passwordCheck != password):
			self.session[REGISTRATION_ERROR_KEY] = REGISTRATION_ERROR_PASSWORD_DOESNT_MATCH
			self.redirect('/registration' + refererUrlPart)
		elif familyName==None or familyName=="" or givenName==None or givenName=="":
			self.session[REGISTRATION_ERROR_KEY] = REGISTRATION_ERROR_USER_NAME_NOT_FILLED
			self.redirect('/registration' + refererUrlPart)
		else:
			#Everything went ok, create the user and log him in
			user = User()
			user.email = email
			user.familyName=familyName
			user.givenName=givenName
			user.password = "[email protected]#"
			m = hashlib.md5()
			encodedString = password.encode('ascii', errors='replace')
			m.update(encodedString)
			user.passwordHash = str(m.hexdigest())
			user.phoneNumber=phoneNumber
			user.activated = False
			user.registrationDate=datetime.datetime.now(timeZone)
			user.referer = referer
			user.sourceOfInfo = sourceOfInfo
			word = ''
			random = Random()
			for i in range(1,32):
				word += random.choice('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789')
			user.activationCode = word			
			user.put()
			updateUser(user)
			template_values = {
				'email':email,
				'activationCode':word,
				'user':user
			}
			messageTemplate = jinja_environment.get_template('templates/userForms/activation/activation_code.html')
			message = mail.EmailMessage(sender="Diet Futar <[email protected]>")
			message.subject="Diet-futar, sikeres regisztracio"
			message.to = email
			message.body = messageTemplate.render(template_values)
			message.send()
			self.redirect("/activationPending")
开发者ID:lajthabalazs,项目名称:diet-futar,代码行数:69,代码来源:user_forms.py


注:本文中的model.User.passwordHash方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。