本文整理汇总了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)
示例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")