def delete_user(user_login): db = UserTable() result = db.delete(user_login) result = {"message": "ok"} if result is None else result return result
def put(self, user_login): ''' 사용자 정보를 수정한다. ''' db = UserTable() user_pass = request.args.get('user_pass') if db.get_auth(user_login, user_pass): return update_user(user_login) else: return "No Permission"
def get(self, user_login): ''' 사용자 상세내역을 조회한다. ''' db = UserTable() user_pass = request.args.get('user_pass') if db.get_auth(user_login, user_pass): return get_user(user_login) else: return "No Permission"
def update_user(user_login): j = request.get_json() db = UserTable() result = db.update(user_login, j) result = {"message": "ok"} if result is None else result return result
def delete(self, user_login): ''' 사용자 정보를 삭제한다 ''' db = UserTable() user_pass = request.args.get('user_pass') if db.get_auth(user_login, user_pass): return delete_user(user_login) else: return "No Permission"
def get(self, user_login): ''' 사용자 인증정보를 인증한다. ''' db = UserTable() user_pass = request.args.get('user_pass') result = db.get_auth(user_login, user_pass) if result: return "Correct Password" else: return "Please make sure the user name and password are correct"
def add_user(): j = request.get_json() print("DEBUG> input ===>{}".format(j)) db = UserTable() result = db.insert(j) result = {"message": "ok"} if result is None else result return result
def list_users(): page = int(request.args.get('page', "0")) np = int(request.args.get('itemsInPage', "20")) db = UserTable() res = db.list(page=page, itemsInPage=np) result = {"users": "{}".format(res), "count": len(res), "page": page} return result
def delete_user(id): db = UserTable() result = db.delete(id) result = {"message": "ok"} if result is None else result response = app.response_class(response=json.dumps(result), status=200, mimetype='application/json') return response
def update_user(id): j = request.get_json() db = UserTable() result = db.update(id, j) result = {"message": "ok"} if result is None else result response = app.response_class(response=json.dumps(result), status=200, mimetype='application/json') return response
def get_user(id): cache = UserCache() result = cache.get_user(id) if result is not None: result = ast.literal_eval(result.decode('utf-8', 'ignore')) else: db = UserTable() result = db.get(id) cache.set_user(id, str(result)) result['token'] = get_raw_jwt() return result
def get_auth(email, passwd): db = UserTable() result = db.auth(email, passwd) # Create the tokens we will be sending back to the user access_token = create_access_token(identity=email) refresh_token = create_refresh_token(identity=email) # Set the JWT cookies in the response resp = jsonify({'login': result}) set_access_cookies(resp, access_token) set_refresh_cookies(resp, refresh_token) return resp
def add_user(): j = request.get_json() print("DEBUG> input ===>{}".format(j)) db = UserTable() result = db.insert(j) result = {"message": "ok"} if result is None else result response = app.response_class(response=json.dumps(result), status=200, mimetype='application/json') return response
def get_user(user_login): db = UserTable() result = db.get(user_login) return result
def get_user(id): db = UserTable() result = db.get(id) return result