Exemplo n.º 1
0
Arquivo: models.py Projeto: nprun/f12
 def authenticate(email, password):
     user = User._get_user_by_email(email)
     if not user:
         return {"status": "InvalidCredentials"}
     elif not user._can_login():
         return {"status": "UserPending"}
     elif user.password == HashUtil.hash(password):
         return {"status": "Authenticated", "email": user.email}
     else:
         return {"status": "InvalidCredentials"}
Exemplo n.º 2
0
Arquivo: models.py Projeto: nprun/f12
    def create(email, password):
        user = User._get_user_by_email(email)
        if user:
            return {"status": "UserExists"}

        password = HashUtil.hash(password)
        user = User(email=email, uc_email=email.upper(), password=password, active=False)
        key = user.put()

        if not key or not key.id():
            return {"status": "UnknownError"}

        user._send_welcome_email()
        return {"status": "UserCreated"}