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


Python Base.make_pw_hash方法代码示例

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


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

示例1: post

# 需要导入模块: import Base [as 别名]
# 或者: from Base import make_pw_hash [as 别名]
  def post(self):
    username = self.request.get("username")
    password = self.request.get("password")
    verify = self.request.get("verify")
    email = self.request.get("email")

    error_username = "" if self.valid_username(username) else "That's not a valid username."
    error_password = "" if self.valid_password(password) else "That wasn't a valid password. At least three characters"
    error_email = "" if self.valid_email(email) else "That's not a valid email."
    error_verify = "" if password == verify else "Your passwords didn't match."

    if (not error_username) and (not error_password) and (not error_verify) and (not error_email):
      if self.check_username(username):
        user = User(username = username, password = password, email = email)
        user_key = user.put()
        user_hash_id = Base.make_pw_hash(username, password, str(user_key.id()))
        self.response.headers.add_header("Set-cookie", "user_id = %s; path = /" % user_hash_id)
        self.redirect("/final")
      else:
        error_username = "This username has been taken."
        self.write_form(error_username, "", error_email, "", "", email)
    else:
      if error_password:
        self.write_form(error_username, error_password, "", error_email, username, email)
      else:
        self.write_form(error_username, error_password, error_verify, error_email, username, email)
开发者ID:ArthurLu,项目名称:Udacity253,代码行数:28,代码来源:Final.py


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