def register_email(name, email, password=None): pwd_hash = generate_password_hash(password) if password else None user = User.find_email(email) if user: raise ExistingUser() user_id = User.create(name, pwd_hash) User.set_email(user_id, email) return user_id
def register_facebook(name, email, facebook_id, user_id=None): user = User.find_facebook(facebook_id) if user: raise ExistingUser() if not user_id: # if not logged in user = User.find_email(email) # find user by email if user: user_id = user.get('user_id') else: user_id = User.create(name) User.set_email(user_id, email) User.set_facebook(user_id, facebook_id) return user_id