def add_claims_to_access_token(identity): urole = AuthModel.find_by_id(identity) print("urole = ", urole.role) if urole.role == 'Admin': return {'role': 'Admin'} elif urole.role == 'Vendor': return {'role': 'Vendor'} else: return {'role': 'Customer'}
def get(self): users = AuthModel.find_by_id(get_jwt_identity()) if users: jti = get_jwt()['jti'] blocklist.add(jti) return { "message": "User Logged out Successfully", "Status": "Success" } return {"Status": "Fail"}, 200
def put(self, id): parse = reqparse.RequestParser() parse.add_argument('password', type=str) data = parse.parse_args() user = AuthModel.find_by_id(id) if user: data = parse.parse_args() user.password = data['password'] user.save_to_db() return {"updated": True, "data": user.json()}, 200
def put(self, id): parse = reqparse.RequestParser() parse.add_argument('username', type=str) parse.add_argument('city', type=str) parse.add_argument('phone', type=str) data = parse.parse_args() user = AuthModel.find_by_id(id) if user: data = parse.parse_args() user.username = data['username'] user.city = data['city'] user.phone = data['phone'] user.save_to_db() return {"updated": True, "data": user.json()}, 200
def get(self): user = AuthModel.find_by_id(get_jwt_identity()) if user: return {"User": user.json(), "status": 'ok'}, 200 return {"message": "User Not Found"}