예제 #1
0
def facebook_register(first_name, last_name, nickname, email, provider, uid):
    """This function registres user through facebook.
    It will insert user's data via insert_user function
    from util.
        :returns True if transaction finished successfully.
    """
    user = get_user_by_oauth_id(uid)
    is_registered = True
    if not user:
        user = get_user_by_email(email)
        is_registered = True
    if not user:
        is_registered = False
        password = random_password(10)
        salted_pass = hash_pass(password)
        role_id = util.get_role_id('user')
        register_user_id = util.facebook_insert(first_name, last_name,
                                                nickname, email, salted_pass,
                                                provider, uid)
        if register_user_id:
            util.add_users_role(register_user_id, role_id[0])
            user = get_user_by_oauth_id(uid)
        message = generate_email(
            'registration', _CONFIG['email.from_address'], email,
            (first_name, last_name, email, password, request.url_root))
        send_email(_CONFIG['email.server_name'], _CONFIG['email.user_name'],
                   _CONFIG['email.server_password'],
                   _CONFIG['email.from_address'], email, message)
    else:
        util.add_oauth_to_user(user.uid, provider, uid)
    return user, is_registered
예제 #2
0
def facebook_register(first_name, last_name, email, provider, uid):
    """This function registres user through facebook.
    It will insert user's data via insert_user function
    from util.
        :returns True if transaction finished successfully.
    """
    user = get_user_by_oauth_id(uid)
    if not user:
        user = get_user_by_email(email)
    if not user:
        password = random_password(10)
        salted_pass = hash_pass(password)
        role_id = util.get_role_id('user')
        register_user_id = util.facebook_insert(first_name,
                                                last_name, email,
                                                salted_pass,
                                                provider, uid)
        if register_user_id:
            util.add_users_role(register_user_id, role_id[0])
            user = get_user_by_oauth_id(uid)
        send_email(_CONFIG['email.user_name'], _CONFIG['email.app_password'],
                   first_name, last_name, email, password)
    else:
        util.add_oauth_to_user(user.uid, provider, uid)
    return user
예제 #3
0
파일: user.py 프로젝트: timbortnik/EcoMap
def register(first_name, last_name, email, password):
    """This function registrates user.
    It will insert user's data via insert_user function
    from util.

        :returns True if transaction finished successfully.
    """
    salted_pass = hash_pass(password)
    role_id = util.get_role_id('user')
    register_user_id = util.insert_user(first_name, last_name, email,
                                        salted_pass)
    if register_user_id:
        util.add_users_role(register_user_id, role_id[0])
    send_email(_CONFIG['email.user_name'], _CONFIG['email.app_password'],
               first_name, last_name, email, password)
    return get_user_by_id(register_user_id)
예제 #4
0
def register(first_name, last_name, email, password):
    """This function registrates user.
    It will insert user's data via insert_user function
    from util.

        :returns True if transaction finished successfully.
    """
    salted_pass = hash_pass(password)
    role_id = util.get_role_id('user')
    register_user_id = util.insert_user(first_name, last_name,
                                        email, salted_pass)
    if register_user_id:
        util.add_users_role(register_user_id, role_id[0])
    send_email(_CONFIG['email.user_name'], _CONFIG['email.app_password'],
               first_name, last_name, email, password)
    return get_user_by_id(register_user_id)
예제 #5
0
def register(first_name, last_name, nickname, email, password):
    """This function registrates user.
    It will insert user's data via insert_user function
    from util.

        :returns True if transaction finished successfully.
    """
    salted_pass = hash_pass(password)
    role_id = util.get_role_id('user')
    register_user_id = util.insert_user(first_name, last_name, nickname, email,
                                        salted_pass)
    if register_user_id:
        util.add_users_role(register_user_id, role_id[0])
    message = generate_email(
        'registration', _CONFIG['email.from_address'], email,
        (first_name, last_name, email, password, request.url_root))
    send_email(_CONFIG['email.server_name'], _CONFIG['email.user_name'],
               _CONFIG['email.server_password'], _CONFIG['email.from_address'],
               email, message)
    return get_user_by_id(register_user_id)
예제 #6
0
파일: user.py 프로젝트: timbortnik/EcoMap
def facebook_register(first_name, last_name, email, provider, uid):
    """This function registres user through facebook.
    It will insert user's data via insert_user function
    from util.
        :returns True if transaction finished successfully.
    """
    user = get_user_by_oauth_id(uid)
    if not user:
        user = get_user_by_email(email)
    if not user:
        password = random_password(10)
        salted_pass = hash_pass(password)
        role_id = util.get_role_id('user')
        register_user_id = util.facebook_insert(first_name, last_name, email,
                                                salted_pass, provider, uid)
        if register_user_id:
            util.add_users_role(register_user_id, role_id[0])
            user = get_user_by_oauth_id(uid)
        send_email(_CONFIG['email.user_name'], _CONFIG['email.app_password'],
                   first_name, last_name, email, password)
    else:
        util.add_oauth_to_user(user.uid, provider, uid)
    return user
예제 #7
0
def register(first_name, last_name, nickname, email, password):
    """This function registrates user.
    It will insert user's data via insert_user function
    from util.

        :returns True if transaction finished successfully.
    """
    salted_pass = hash_pass(password)
    role_id = util.get_role_id('user')
    register_user_id = util.insert_user(first_name, last_name,
                                        nickname, email, salted_pass)
    if register_user_id:
        util.add_users_role(register_user_id, role_id[0])
    message = generate_email('registration', _CONFIG['email.from_address'],
                             email, (first_name, last_name, email,
                             password, request.url_root))
    send_email(_CONFIG['email.server_name'],
               _CONFIG['email.user_name'],
               _CONFIG['email.server_password'],
               _CONFIG['email.from_address'],
               email,
               message)
    return get_user_by_id(register_user_id)
예제 #8
0
def facebook_register(first_name, last_name, nickname, email, provider, uid):
    """This function registres user through facebook.
    It will insert user's data via insert_user function
    from util.
        :returns True if transaction finished successfully.
    """
    user = get_user_by_oauth_id(uid)
    is_registered = True
    if not user:
        user = get_user_by_email(email)
        is_registered = True
    if not user:
        is_registered = False
        password = random_password(10)
        salted_pass = hash_pass(password)
        role_id = util.get_role_id('user')
        register_user_id = util.facebook_insert(first_name,
                                                last_name,
                                                nickname, email,
                                                salted_pass,
                                                provider, uid)
        if register_user_id:
            util.add_users_role(register_user_id, role_id[0])
            user = get_user_by_oauth_id(uid)
        message = generate_email('registration', _CONFIG['email.from_address'],
                                 email, (first_name, last_name,
                                 email, password, request.url_root))
        send_email(_CONFIG['email.server_name'],
                   _CONFIG['email.user_name'],
                   _CONFIG['email.server_password'],
                   _CONFIG['email.from_address'],
                   email,
                   message)
    else:
        util.add_oauth_to_user(user.uid, provider, uid)
    return user, is_registered