Exemple #1
0
 def test_login(self):
     may_exist_user = user_from_facebook_id(args['facebook_id'])
     response = login_request_impl(args)
     if may_exist_user is not None:
         assert response['message'] == "Login Succeed"
     else:
         assert response['message'] == "Sign Up Succeed"
Exemple #2
0
def login_request_impl(args):
    try:
        user = user_from_facebook_id(args['facebook_id'])
        delete_last_token_from_facebook_id(args['facebook_id'])
        if user is not None:
            __set_values_for_user_from_args(user, args)
            __generate_token_for_user(user)

            #needs to call it to assign to builtin, we need to use it later on group hybrid property.
            user_from_token(user.user_token.token)

            user_groups = json.loads(GroupSchema(many=True).dumps(groups_from_user(user)).data)
            user_data = json.loads(MyselfSchema().dumps(user).data)
            return Response(True, "Login Succeed", json.dumps(dict(groups=user_groups, myself=user_data))).output()
        else:
            return signup_request_impl(args)
    except Exception as exception:
        return Response(False, str(exception), None).output()