コード例 #1
0
def add_user(username: str, password: str, repo: AbstractRepository):
    if repo.get_user(username):
        raise DuplicatedUsernameException
    password_hash = generate_password_hash(password)
    new_user = User(username, password_hash)
    repo.add_user(new_user)
    if has_app_context():
        _save_users_to_disk(current_app.config['USER_DATA_PATH'], repo)
コード例 #2
0
def add_user(username: str, password: str, repo: AbstractRepository):
    # Check that the given username is available.
    user = repo.get_user(username)
    if user is not None:
        raise NameNotUniqueException

    # Encrypt password so that the database doesn't store passwords 'in the clear'.
    password_hash = generate_password_hash(password)

    # Create and store the new User, with password encrypted.
    user = User(username, password_hash)
    repo.add_user(user)
コード例 #3
0
ファイル: services.py プロジェクト: NeedsSoySauce/MyMovieList
def add_user(repo: AbstractRepository, username: str, password: str) -> None:
    """ Adds the given user to the given repository. """
    # Check that the given username is available.
    if check_if_user_exists(repo, username):
        raise NameNotUniqueException

    # Encrypt password so that the database doesn't store passwords 'in the clear'.
    password_hash = generate_password_hash(password)

    # Create and store the new User, with password encrypted.
    user = User(username, password_hash)
    repo.add_user(user)
コード例 #4
0
ファイル: services.py プロジェクト: zixuansu/MOVIE2_APP
def user_register(username: str, password: str, repo: AbstractRepository):
    user = repo.get_user(username)
    messages = {'state': False}
    if user is not None:
        messages['error'] = 'The user has been registered'
        return messages
    else:
        user = User(username, password)
        repo.add_user(user)
        messages['state'] = True
        messages['error'] = 'register successfully'
        return messages
        '''
コード例 #5
0
def add_user(username: str, password: str, repo: AbstractRepository):
    if repo.get_user(username):
        raise DuplicatedUsernameException
    password_hash = generate_password_hash(password)
    new_user = User(username, password_hash)
    repo.add_user(new_user)