diff --git a/api/chalicelib/core/users.py b/api/chalicelib/core/users.py index 7803afa4b..07e4a1bf1 100644 --- a/api/chalicelib/core/users.py +++ b/api/chalicelib/core/users.py @@ -443,7 +443,12 @@ def change_password(tenant_id, user_id, email, old_password, new_password): r = authenticate(user['email'], new_password) return { - 'jwt': r.pop('jwt') + "jwt": r.pop("jwt"), + "refreshToken": r.pop("refreshToken"), + "refreshTokenMaxAge": r.pop("refreshTokenMaxAge"), + "spotJwt": r.pop("spotJwt"), + "spotRefreshToken": r.pop("spotRefreshToken"), + "spotRefreshTokenMaxAge": r.pop("spotRefreshTokenMaxAge") } diff --git a/api/routers/core.py b/api/routers/core.py index 59ff60ccd..13dc9a563 100644 --- a/api/routers/core.py +++ b/api/routers/core.py @@ -764,14 +764,6 @@ def generate_new_user_token(context: schemas.CurrentContext = Depends(OR_context return {"data": users.generate_new_api_key(user_id=context.user_id)} -@app.post('/account/password', tags=["account"]) -def change_client_password(data: schemas.EditUserPasswordSchema = Body(...), - context: schemas.CurrentContext = Depends(OR_context)): - return users.change_password(email=context.email, old_password=data.old_password.get_secret_value(), - new_password=data.new_password.get_secret_value(), tenant_id=context.tenant_id, - user_id=context.user_id) - - @app.post('/{projectId}/saved_search', tags=["savedSearch"]) def add_saved_search(projectId: int, data: schemas.SavedSearchSchema = Body(...), context: schemas.CurrentContext = Depends(OR_context)): diff --git a/api/routers/core_dynamic.py b/api/routers/core_dynamic.py index fc48c72e8..5cdd4dc72 100644 --- a/api/routers/core_dynamic.py +++ b/api/routers/core_dynamic.py @@ -148,6 +148,16 @@ def change_scope(data: schemas.ScopeSchema = Body(), return {'data': data} +@app.post('/account/password', tags=["account"]) +def change_client_password(resqponse: JSONResponse, data: schemas.EditUserPasswordSchema = Body(...), + context: schemas.CurrentContext = Depends(OR_context)): + r = users.change_password(email=context.email, old_password=data.old_password.get_secret_value(), + new_password=data.new_password.get_secret_value(), tenant_id=context.tenant_id, + user_id=context.user_id) + r = __process_authentication_response(response=resqponse, data=r) + return r + + @app.post('/integrations/slack', tags=['integrations']) @app.put('/integrations/slack', tags=['integrations']) def add_slack_integration(data: schemas.AddCollaborationSchema, diff --git a/ee/api/chalicelib/core/users.py b/ee/api/chalicelib/core/users.py index 14d4e65bb..ee2a1e0b9 100644 --- a/ee/api/chalicelib/core/users.py +++ b/ee/api/chalicelib/core/users.py @@ -525,7 +525,12 @@ def change_password(tenant_id, user_id, email, old_password, new_password): r = authenticate(user['email'], new_password) return { - 'jwt': r.pop('jwt') + "jwt": r.pop("jwt"), + "refreshToken": r.pop("refreshToken"), + "refreshTokenMaxAge": r.pop("refreshTokenMaxAge"), + "spotJwt": r.pop("spotJwt"), + "spotRefreshToken": r.pop("spotRefreshToken"), + "spotRefreshTokenMaxAge": r.pop("spotRefreshTokenMaxAge") } diff --git a/ee/api/routers/core_dynamic.py b/ee/api/routers/core_dynamic.py index e0387fdd9..b94aab462 100644 --- a/ee/api/routers/core_dynamic.py +++ b/ee/api/routers/core_dynamic.py @@ -153,6 +153,16 @@ def change_scope(data: schemas.ScopeSchema = Body(), return {'data': data} +@app.post('/account/password', tags=["account"]) +def change_client_password(resqponse: JSONResponse, data: schemas.EditUserPasswordSchema = Body(...), + context: schemas.CurrentContext = Depends(OR_context)): + r = users.change_password(email=context.email, old_password=data.old_password.get_secret_value(), + new_password=data.new_password.get_secret_value(), tenant_id=context.tenant_id, + user_id=context.user_id) + r = __process_authentication_response(response=resqponse, data=r) + return r + + @app.post('/integrations/slack', tags=['integrations']) @app.put('/integrations/slack', tags=['integrations']) def add_slack_integration(data: schemas.AddCollaborationSchema,