Redirect user to login when they reset their own sessions/API tokens from admin user management page (#1240)

* Redirect to login when user resets their sessions

* Update Cypress test
This commit is contained in:
gillespi314 2021-06-28 19:33:05 -05:00 committed by GitHub
parent 959c1fda81
commit 917e1886d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View file

@ -33,7 +33,7 @@ describe("Reset user sessions flow", () => {
cy.findByText(/reset sessions/i).should("exist");
cy.findByRole("button", { name: /confirm/i }).click();
});
cy.findByText(/sessions reset/i).should("exist");
cy.findByText(/reset sessions/i).should("not.exist");
// user should be logged out now so log in again and go to profile to get new API token
cy.visit("/");

View file

@ -216,12 +216,16 @@ export class UserManagementPage extends Component {
};
onResetSessions = () => {
const { dispatch } = this.props;
const { LOGIN } = paths;
const { currentUser, dispatch } = this.props;
const { userEditing } = this.state;
const { toggleResetSessionsUserModal } = this;
dispatch(userActions.deleteSessions(userEditing))
.then(() => {
dispatch(renderFlash("success", "Sessions reset"));
if (currentUser.id === userEditing.id) {
dispatch(push(LOGIN));
}
})
.catch(() => {
dispatch(