-
Notifications
You must be signed in to change notification settings - Fork 700
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added password reset as a route to manage initial login case (#…
…4744) * feat: Added password reset as a route to manage initial login case Signed-off-by: Hrishav <hrishav.kumar@harness.io> * feat: Fixed deepspan issue Signed-off-by: Hrishav <hrishav.kumar@harness.io> * fix: Updated API response in front-end Signed-off-by: Hrishav <hrishav.kumar@harness.io> * chore: addressed review comment Signed-off-by: Hrishav <hrishav.kumar@harness.io> --------- Signed-off-by: Hrishav <hrishav.kumar@harness.io>
- Loading branch information
1 parent
00f0bd7
commit fb46bb9
Showing
23 changed files
with
347 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
chaoscenter/web/src/api/auth/schemas/ResponseErrInvalidCredentials.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* eslint-disable */ | ||
// This code is autogenerated using @harnessio/oats-cli. | ||
// Please do not modify this code directly. | ||
|
||
export interface ResponseErrInvalidCredentials { | ||
/** | ||
* @example "The old and new passwords can't be same" | ||
*/ | ||
error?: string; | ||
/** | ||
* @example "The old and new passwords can't be same" | ||
*/ | ||
errorDescription?: string; | ||
} |
14 changes: 14 additions & 0 deletions
14
chaoscenter/web/src/api/auth/schemas/ResponseErrOldPassword.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* eslint-disable */ | ||
// This code is autogenerated using @harnessio/oats-cli. | ||
// Please do not modify this code directly. | ||
|
||
export interface ResponseErrOldPassword { | ||
/** | ||
* @example "The old and new passwords can't be same" | ||
*/ | ||
error?: string; | ||
/** | ||
* @example "The old and new passwords can't be same" | ||
*/ | ||
errorDescription?: string; | ||
} |
7 changes: 7 additions & 0 deletions
7
chaoscenter/web/src/api/auth/schemas/ResponseMessageResponse.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* eslint-disable */ | ||
// This code is autogenerated using @harnessio/oats-cli. | ||
// Please do not modify this code directly. | ||
|
||
export interface ResponseMessageResponse { | ||
message?: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
chaoscenter/web/src/controllers/PasswordReset/PasswordReset.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import React from 'react'; | ||
import { useToaster } from '@harnessio/uicore'; | ||
import { useHistory } from 'react-router-dom'; | ||
import PasswordResetView from '@views/PasswordReset'; | ||
import { useGetUserQuery, useUpdatePasswordMutation } from '@api/auth'; | ||
import { getUserDetails, setUserDetails } from '@utils'; | ||
import { normalizePath } from '@routes/RouteDefinitions'; | ||
|
||
const PasswordResetController = (): React.ReactElement => { | ||
const { accountID, projectID } = getUserDetails(); | ||
const { showSuccess, showError } = useToaster(); | ||
const history = useHistory(); | ||
|
||
const { data: currentUserData, isLoading: getUserLoading } = useGetUserQuery( | ||
{ | ||
user_id: accountID | ||
}, | ||
{ | ||
enabled: !!accountID | ||
} | ||
); | ||
|
||
const { mutate: updatePasswordMutation, isLoading: updatePasswordLoading } = useUpdatePasswordMutation( | ||
{}, | ||
{ | ||
onSuccess: data => { | ||
setUserDetails({ isInitialLogin: false }); | ||
showSuccess(`${data.message}`); | ||
history.push(normalizePath(`/account/${accountID}/project/${projectID}/dashboard`)); | ||
}, | ||
onError: err => showError(err.errorDescription) | ||
} | ||
); | ||
|
||
return ( | ||
<PasswordResetView | ||
currentUserData={currentUserData} | ||
updatePasswordMutation={updatePasswordMutation} | ||
loading={{ | ||
getUser: getUserLoading, | ||
updatePassword: updatePasswordLoading | ||
}} | ||
/> | ||
); | ||
}; | ||
|
||
export default PasswordResetController; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import PasswordResetController from './PasswordReset'; | ||
|
||
export default PasswordResetController; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.