예제 #1
0
 def renew_activation_token(self, email):
     if not self.exists(email):
         return
     if self.is_activated(email):
         return
     activation_token = crypto.create_activation_token()
     self._db_connection.execute_non_query(
         ("UPDATE users SET activation_token = %s, activation_token_requested = NOW()"
         "WHERE email = %s"), (activation_token, email)
     )
     return activation_token
예제 #2
0
 def create(self, email, password):
     if self.exists(email):
         raise EmailAlreadyInUseError(email)
     if len(email) > 100:
         raise EmailTooLongError(email, 100)
     activation_token = crypto.create_activation_token()
     salt = crypto.create_salt()
     hashed_password = crypto.create_hash(password,salt)
     self._db_connection.execute_non_query(
         ("INSERT INTO users (email, password, salt, activation_token, activation_token_requested, created)"
         "VALUES (%s, %s, %s, %s, NOW(), NOW())"),
         (email, hashed_password, salt, activation_token)
     )
     return activation_token