Example #1
0
def create_user(name, email, password, confirm):

    is_valid = True
    error_msg = []

    is_valid = not is_blank('name', name, error_msg)
    is_valid = not is_blank('email', email, error_msg)
    is_valid = not is_blank('password', password, error_msg)
    is_valid = not is_blank('confirm', confirm, error_msg)

    if not EMAIL_REGEX.match(email):
        is_valid = False
        error_msg.append('invalid email format')

    if password != confirm:
        is_valid = False
        error_msg.append('password did not match')
    
    if(len(password) < 6):
        is_valid = False
        error_msg.append('password is too short')    

    if is_valid:
        try:
            user = User()
            user.name = name
            user.email = email
            user.password = password
            db.save(user)
            return user
        except:
            error_msg.append('email already registered.')


    return error_msg
Example #2
0
def create_user(name, email, password, confirm):
    error_message = []
    # 4 is not blank
    if len(name) == 0:
        error_message.append('Name cannot be empty')
    if len(email) == 0:
        error_message.append('Email cannot be empty')
    if len(password) == 0:
        error_message.append('Password cannot be empty')
    if len(confirm) == 0:
        error_message.append('Confirm Password cannot be empty')
    # password length more than 6
    if len(password) < 6:
        error_message.append('Password must be at least 6 character')
    # password and confirm is match
    if password != confirm:
        error_message.append('Password not match')

    if len(error_message) == 0:
        db = DbManager()
        try:
            user = User()
            user.name = name
            user.email = email
            encoded = password.encode('UTF-8')
            encrypted = bcrypt.hashpw(encoded, bcrypt.gensalt())
            user.password = password
            db.save(user)
            return user
        except:
            error_message.append('Email already exist')

    return error_message
Example #3
0
def create_user(email, fullname, password):
    user = User()
    user.email = email
    user.fullname = fullname
    user.password = password
    db.save(user)
    return user
Example #4
0
def create_user(email, name, password):
    user = User()
    user.name = name
    user.email = email
    user.password = password
    return db.save(user)
Example #5
0
def create_user(email, fullname, hashed_pw):
    user = User()
    user.email = email
    user.fullname = fullname
    user.hashed_pw = hashed_pw
    return db.save(user)