Пример #1
0
def update_user(uuid, email, name, new_password, current_password=None):
    user = User.get(uuid=uuid)
    if user.password_hash:
        verified = authenticate_password(current_password, user.password_hash)
        if not verified:
            raise Exception("Current password does not match user password.")
    password_hash = hash_password(new_password)
    user = User.update(uuid,
                       name=name,
                       password_hash=password_hash)
    return user
Пример #2
0
def update_user(uuid, email, name, new_password, current_password=None):
    user = User.get(uuid=uuid)
    if user.password_hash:
        verified = authenticate_password(current_password, user.password_hash.encode('utf-8'))
        if not verified:
            raise Exception("Current password does not match user password.")
    password_hash = hash_password(new_password)
    print password_hash
    user = User.update(uuid,
                       name=name,
                       password_hash=password_hash)
    return user
Пример #3
0
    def update_user(uuid, **kwargs):
        user = User.get(uuid=uuid)
        if not user:
            return None

        if kwargs.get('password'):
            kwargs['password_hash'] = hash_password(kwargs['password'])

        email = kwargs.get('email')
        if email and user.email != email:
            other_user = User.get(email=email)
            if other_user and other_user != user:
                raise Exception("A user with this email address already exists: {}".format(email))

        user.update(**kwargs)
        return user
Пример #4
0
import sys

from app.db.user import create_user
from app.utils.crypto import hash_password


if __name__ == "__main__":
    email = sys.argv[1]
    password = hash_password(sys.argv[2])
    create_user(email, password)
Пример #5
0
 def update_password(self, new_password):
     new_password = hash_password(new_password)
     self.update(password_hash=new_password)