Exemple #1
0
 def post(self, **params):
     """Logic for creating a user"""
     try:
         user = User(**params).save()
     except exceptions.UniqueProperty:
         return abort(409, "Username or Email already taken")
     return user
Exemple #2
0
def _get_user_from_google_token(token):
    """Checks if a user can be obtained with the given token
    and if not, creates a new user.

    :param token: id_token returned by google login
    :return: instance of User
    """
    google_id, email = validate_google_id_token(token)
    google_auth = GoogleOAuth.find_by(user_id=google_id, force=False)
    if not google_auth:
        user = User.find_by(email=email, force=False)
        if not user:
            user = User(email=email, username=email, password=None).save()
        google_auth = GoogleOAuth(user_id=google_id).save()
        google_auth.user_rel.connect(user)  # pylint:disable=no-member
    else:
        user = google_auth.user
    return user
Exemple #3
0
 def build_user(cls, username="******", email="*****@*****.**"):
     return User(username=username, email=email, password="******")