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
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
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)
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)
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)
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