Exemplo n.º 1
0
 def get(self, hobby, start_date, end_date):
     '''Get user's hobby'''
     try:
         resp = User().get_data_by_hobby_between(hobby, start_date, end_date)
         return masked_json_template(resp, 200)
     except:
         abort(400, "Input unrecognizable.")
Exemplo n.º 2
0
 def delete(self, userid):
     '''Delete user data by user ID'''
     try:
         resp = User().delete_data_by_userid(userid)
         return masked_json_template(resp, 200)
     except:
         abort(400, "Input unrecognizable.")
Exemplo n.º 3
0
 def get(self, hobby, register_after):
     '''Get user's hobby'''
     try:
         resp = User().get_data_by_hobby(hobby, register_after)
         return masked_json_template(resp, 200)
     except:
         abort(400, "Input unrecognizable.")
Exemplo n.º 4
0
 def get(self, username):
     '''Get user data by username'''
     try:
         resp = User().get_data_by_username(username)
         return masked_json_template(resp, 200)
     except:
         abort(400, "Input unrecognizable.")
Exemplo n.º 5
0
 def post(self):
     '''Add new user'''
     try:
         json_data = api.payload
         resp = User().register(json_data)
         return masked_json_template(resp, 200)
     except:
         abort(400, "Input unrecognizable.")
Exemplo n.º 6
0
 def put(self, userid):
     '''Update user data by user ID'''
     try:
         json_data = api.payload
         resp = User().update_data_by_userid(userid, json_data)
         return masked_json_template(resp, 200)
     except:
         abort(400, "Input unrecognizable.")
Exemplo n.º 7
0
 def get(self):
     '''Retrieve login status'''
     is_valid, code, msg = is_token_valid(
         request.headers.get('Authorization'))
     if is_valid:
         return masked_json_template({"response": True}, 200)
     else:
         abort(code, msg)
Exemplo n.º 8
0
 def get(self):
     '''Logout and autoamatically revoke current access_token (PS: refresh_token still can be used)'''
     is_valid, code, msg = is_token_valid(
         request.headers.get('Authorization'))
     if is_valid:
         encoded_token = request.headers.get('Authorization').replace(
             'Bearer ', '')
         resp = User().do_logout(encoded_token=encoded_token)
         return masked_json_template(resp, 200)
     else:
         abort(code, msg)
Exemplo n.º 9
0
 def post(self):
     '''Login using Binary Token to get Server Token'''
     try:
         json_data = api.payload
         resp = User().validate_user(json_data=json_data)
         return masked_json_template(resp, 200)
     except:
         resp = get_json_template(response=False,
                                  message="No Json Input Found.",
                                  results=-1,
                                  total=-1)
         return resp, 404
Exemplo n.º 10
0
 def delete(self):
     '''Delete all existing User data'''
     try:
         try:
             get_args = {
                 "filter": request.args.get('filter', default="{}", type=str),
                 "range": request.args.get('range', default="[]", type=str),
                 "sort": request.args.get('sort', default="[]", type=str)
             }
         except:
             get_args = None
         resp = User().delete_all_user_data(get_args)
         return masked_json_template(resp, 200)
     except:
         abort(400, "Input unrecognizable.")
Exemplo n.º 11
0
    def get(self):
        '''Get all user data'''
        try:
            try:
                get_args = {
                    "filter": request.args.get('filter', default="", type=str),
                    "range": request.args.get('range', default="", type=str),
                    "sort": request.args.get('sort', default="", type=str)
                }
            except:
                get_args = None

            resp = User().get_users(get_args)
            if resp["results"] is None:
                resp["results"] = []
            return masked_json_template(resp, 200, no_checking=True)
        except:
            abort(400, "Input unrecognizable.")