本文整理汇总了Python中model.User.User.user_activation_key方法的典型用法代码示例。如果您正苦于以下问题:Python User.user_activation_key方法的具体用法?Python User.user_activation_key怎么用?Python User.user_activation_key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.User.User
的用法示例。
在下文中一共展示了User.user_activation_key方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from model.User import User [as 别名]
# 或者: from model.User.User import user_activation_key [as 别名]
def post(self):
validcode = self.get_request("validcode", "")
if "validcode" in self.session:
if validcode != self.session['validcode'] :
self.print_result(False, "ValidCode is incorrect!!")
return
else:
self.print_result(False, "ValidCode is incorrect!!")
return
user = User().getByID(self.userID, False)
if user :
# found it
# send email
activationKey = user.getEncodeStr(str(user.user_login)+"-"+ str(time.time()))
user.user_activation_key = activationKey
if user.update() :
self.print_result(True, "Done")
"""
Send Email to register
"""
msg = self.render_string("email/register.html",activationKey=activationKey, login_user = user.user_login, website_url= self.webroot_url("", True), web_title = self.web_title() )
subject = "["+self.web_title()+"] ReSend Activation Key"
qm = SingleMail.get_instance()
qm.send_email(user.user_email,subject, msg, 'html')
else :
self.print_result(False, "Failed to Update DB")
else:
# find failed
self.print_result(False, "Can not find any record")
示例2: get
# 需要导入模块: from model.User import User [as 别名]
# 或者: from model.User.User import user_activation_key [as 别名]
def get(self):
tid = self.get_request("id", "")
user = None
if (id != ""):
user = User().getByActivateToken(tid, False)
success = False
login = ""
if not user is None:
user.user_status = 1
user.user_activation_key = ""
login = user.user_login
if user.update():
success = True
self.render("public/activate_account.html", login_name=login, title="Activate Account", isSuccess=success)
示例3: post
# 需要导入模块: from model.User import User [as 别名]
# 或者: from model.User.User import user_activation_key [as 别名]
def post(self):
canRegister = pyCache.WebOptions['users_can_register']
if canRegister !='1':
self.print_result(False, "registration is now closed!")
return
account = self.get_request("account", "")
email = self.get_request("email", "")
url = self.get_request("personal_url", "", False)
displayName = self.get_request("display_name", "")
password = self.get_request("password", "")
validcode = self.get_request("valid_code", "")
if not pyUtility.isAccountLegal(account):
self.print_result(False, "The Format of Account is wrong!")
return
if not pyUtility.isEmail(email):
self.print_result(False, "The Format of Email is wrong!")
return
if not url =="":
tmp = url.lower()
if not tmp.startswith("http"):
url = "http://"+url
if not pyUtility.isURL(url):
self.print_result(False, "The Format of URL is wrong!")
return
if account == "" or email == "" or password == "" or validcode == "":
self.print_result(False, "some of fields can not be blank")
return
if "registercode" in self.session:
if validcode != self.session['registercode']:
del self.session['registercode']
self.print_result(False, "Validation Code is incorrect!")
return
else:
self.print_result(False, "Validation Code is empty!")
return
# register process
del self.session['registercode']
chk = User().isUnique(acc=account, email=email)
if not chk:
self.print_result(False, "Account or Email has been used, Try another one!")
return
user = User()
user.user_login = account
user.user_email = email
user.user_pass = user.getEncodeStr(password)
user.user_url = url
user.display_name = displayName
# ts = str(time.time())
activationKey = user.getEncodeStr(str(account) + "-secret-")
user.user_activation_key = activationKey
if user.save() >0:
self.print_result(True, "The Register Letter Has been sent to your email.")
"""
Send Email to register
"""
p = dict(
activationKey=activationKey,
login_user=account,
admin_email=pyCache.WebOptions['admin_email'],
website_url=self.webroot_url("", True)
)
msg = self.render_string("email/register.html", **p)
subject = "[" + self.web_title() + "] Thank you for joining us"
qm = SingleMail.get_instance()
qm.send_email(email, subject, msg, 'html')
else:
self.print_result(False, "Error, When save to db")