-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds resend invite button to user admin page.
If a user has not yet changed their password or lost their invite email, this button will reset the time limit to login and send out a new random password.
- Loading branch information
1 parent
9661b49
commit 3c68672
Showing
6 changed files
with
132 additions
and
21 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { Button, Popconfirm, message } from "antd"; | ||
import { QuestionCircleOutlined } from "@ant-design/icons"; | ||
import { PropTypes } from "prop-types"; | ||
import { API } from "aws-amplify"; | ||
import { useQueryClient } from "react-query"; | ||
|
||
export default function ResetUser({ username, status }) { | ||
const queryClient = useQueryClient(); | ||
|
||
function resetUser() { | ||
API.post("AppStreamAPI", "resetUserPassword", { | ||
body: { username }, | ||
}) | ||
.then(() => { | ||
queryClient.invalidateQueries("users"); | ||
message.success(`resetting password for user: ${username}`); | ||
}) | ||
.catch((e) => { | ||
const responseMessage = e?.response?.data?.message || e.message; | ||
message.error(responseMessage); | ||
}); | ||
} | ||
|
||
function resendInvite() { | ||
API.post("AppStreamAPI", "/addUser", { | ||
body: { username, resend: 1 }, | ||
}) | ||
.then(() => { | ||
queryClient.invalidateQueries("users"); | ||
message.success(`resending invite for user: ${username}`); | ||
}) | ||
.catch((e) => { | ||
const responseMessage = e?.response?.data?.message || e.message; | ||
message.error(responseMessage); | ||
}); | ||
} | ||
|
||
if (status === "FORCE_CHANGE_PASSWORD") { | ||
return ( | ||
<Popconfirm | ||
title="Are you sure?" | ||
okText="Yes" | ||
cancelText="No" | ||
onConfirm={resendInvite} | ||
icon={<QuestionCircleOutlined style={{ color: "red" }} />} | ||
> | ||
<Button>Resend Invite</Button> | ||
</Popconfirm> | ||
); | ||
} | ||
return null; | ||
} | ||
|
||
ResetUser.propTypes = { | ||
username: PropTypes.string.isRequired, | ||
status: PropTypes.string.isRequired, | ||
}; |