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


Python User.slow_hash方法代码示例

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


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

示例1: post

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import slow_hash [as 别名]
 def post(self):
   session = get_current_session()
   nickname = helper.sanitizeHtml(self.request.get('nickname'))
   email    = helper.sanitizeHtml(self.request.get('email'))
   password = helper.sanitizeHtml(self.request.get('password'))
   
   if len(nickname) > 1 and len(password) > 1 and len(email) > 1:
     password = User.slow_hash(password);
     already = User.all().filter("lowercase_nickname =",nickname.lower()).fetch(1)
     if len(already) == 0:
       user = User(nickname=nickname, lowercase_nickname=nickname.lower(),email=email,password=password, about="")
       user.put()
       helper.killmetrics("Register",nickname, "do", session, "",self)
       random_id = helper.get_session_id(session) 
       if session.is_active():
         session.terminate()
       session.regenerate_id()
       session['random_id'] = random_id
       session['user'] = user
       self.redirect('/')
     else:
       session['register_error'] = "Ya existe alguien con ese nombre de usuario <strong>" + nickname + "</strong>"
       self.redirect('/login')
   else:
     session['register_error'] = "Porfavor escribe un username y un password"
     self.redirect('/login')
开发者ID:cesarsalazar,项目名称:Fogata,代码行数:28,代码来源:RegisterHandler.py

示例2: post

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import slow_hash [as 别名]
    def post(self):
        session = get_current_session()
        if session.has_key('user'):
            user = session['user']

        r = self.request
        email       = r.get('email')
        pass1       = r.get('passwd')
        pass2       = r.get('re_passwd')
        fname       = r.get('firstname')
        lname       = r.get('lastname')
        about       = r.get('about')
        twitter     = r.get('twitter')
        location    = r.get('location')
        error = []

        if len(pass1):
            if len(pass2):
                if len(pass2):
                    if pass1 == pass2:
                        if len(pass1.strip()) >= 5:
                            user.password = User.slow_hash( pass1 )
                        else:
                            error.append('The password must be at least 6 chars')
                    else:
                        error.append('Password do not match.')
        

        if email_re.match(email):
            if email != user.email:
                if User.is_email_exists(email):
                    error.append('Sorry, this email is already in use')
                else:
                    user.email = email
        else:
            error.append('Sorry, is not a valid email address')

        if len(error):
            session['profile_fail'] = True;
            session['profile_errors'] = error;
        else:
            user.firstname  = fname
            user.lastname   = lname
            user.about      = about
            user.twitter    = twitter
            user.location   = location
            user.put()
            session['profile_updated'] = True;
        
        self.redirect('/account')
开发者ID:Tmeister,项目名称:pykochr,代码行数:52,代码来源:account.py

示例3: post

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import slow_hash [as 别名]
  def post(self):
    # TODO: Future; allow the session to store if we got here redirected and redirect back there
    nickname = sanitizeHtml(self.request.get('nickname'))
    password = sanitizeHtml(self.request.get('password'))
    password = User.slow_hash(password);

    user = User.all().filter('lowercase_nickname =',nickname.lower()).filter('password =',password).fetch(1)
    if len(user) == 1:
      session = get_current_session()
      if session.is_active():
        session.terminate()
      session.regenerate_id()
      session['user'] = user[0]
      self.redirect('/')
    else:
      self.redirect('/login')
开发者ID:IPGlider,项目名称:Noticias-HAcker,代码行数:18,代码来源:main.py

示例4: post

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import slow_hash [as 别名]
  def post(self):
    session = get_current_session()
    nickname = helper.sanitizeHtml(self.request.get('nickname'))
    password = helper.sanitizeHtml(self.request.get('password'))
    password = User.slow_hash(password);

    user = User.all().filter('lowercase_nickname =',nickname.lower()).filter('password =',password).fetch(1)
    if len(user) == 1:
      if session.is_active():
        session.terminate()
      session.regenerate_id()
      session['user'] = user[0]
      self.redirect('/')
    else:
      session['login_error'] = "Usuario y password incorrectos"
      session['login_error_nickname'] = nickname
      self.redirect('/login')
开发者ID:mantus,项目名称:Noticias-HAcker,代码行数:19,代码来源:main.py

示例5: get

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import slow_hash [as 别名]
    def get(self):
        fbcookie = facebook.get_user_from_cookie(self.request.cookies)
        if not fbcookie:
            self.redirect('/')
            return
        
        user = User.is_logged(self)
        graph = facebook.GraphAPI(fbcookie["access_token"])
        profile = graph.get_object("me")
        if not user:
            password = helpers.random_string(8)
            user = User(nickname = profile['username'].lower(), password = User.slow_hash(password));
            user.fb_access_token = fbcookie["access_token"]
            try: user.about = profile['bio'] 
            except: pass

            try: user.location = profile['location']['name'] 
            except: pass    

            try: user.firstname = profile['first_name'] 
            except: pass    

            try: user.lastname = profile['last_name'] 
            except: pass    

            try: user.fb_profile_url = profile['link']
            except: pass    

            try: user.fb_ui = profile['id']
            except: pass    

            user.put()

            session = get_current_session()
            session.regenerate_id()
            session['user'] = user
            self.redirect('/')
        else:
            if str(user.fb_ui) == str(profile['id']):
                self.redirect('/')
            else:
                #TODO
                #USUARIO CAMBIO DE ID?? o ESTA VINCULANDO A CUENTA EXISTENTE
                pass
开发者ID:Tmeister,项目名称:pykochr,代码行数:46,代码来源:account.py

示例6: post

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import slow_hash [as 别名]
    def post(self):
        session = get_current_session()
        nickname = helper.sanitizeHtml(self.request.get("nickname"))
        password = helper.sanitizeHtml(self.request.get("password"))
        password = User.slow_hash(password)

        user = User.all().filter("lowercase_nickname =", nickname.lower()).filter("password =", password).fetch(1)
        if len(user) == 1:

            helper.killmetrics("Login", nickname, "do", session, "", self)
            random_id = helper.get_session_id(session)
            if session.is_active():
                session.terminate()
            session.regenerate_id()
            session["random_id"] = random_id
            session["user"] = user[0]
            self.redirect("/")
        else:
            session["login_error"] = "Tu usuario y/o contraseña son incorrectos"
            session["login_error_nickname"] = nickname
            self.redirect("/login")
开发者ID:cesarsalazar,项目名称:Fogata,代码行数:23,代码来源:LoginHandler.py

示例7: post

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import slow_hash [as 别名]
 def post(self,code):
   session = get_current_session()
   code = helper.parse_post_id(helper.sanitizeHtml(self.request.get('code')))
   password = helper.sanitizeHtml(self.request.get('password'))
   password_confirm = helper.sanitizeHtml(self.request.get('password_confirm'))
   if password != password_confirm :
     session['error'] = "Ocurrió un error al confirmar el password"
     self.redirect('/recovery/'+code)
     return
   ticket = Ticket.all().filter('code',code).filter('is_active',True).fetch(1)
   if len(ticket) == 1:
     ticket = ticket[0]
     user = ticket.user
     user.password = User.slow_hash(password)
     user.put()
     ticket.is_active = False
     ticket.put()
     session['success'] = "Se ha cambiado el password correctamente, ya puedes iniciar sesión con tus nuevas credenciales"
     self.redirect('/login')
   else:
     self.redirect('/')
开发者ID:DFectuoso,项目名称:Noticias-HAcker,代码行数:23,代码来源:RecoveryHandler.py


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