🚧 Add client password reset
This commit is contained in:
@@ -103,6 +103,13 @@ export function ClientsPage() {
|
|||||||
onError: (e: Error) => setError(e.message),
|
onError: (e: Error) => setError(e.message),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const resetPassword = useMutation({
|
||||||
|
mutationFn: (username: string) =>
|
||||||
|
api.post<PasswordReset>(`/mqtt/clients/${username}/password:reset`),
|
||||||
|
onSuccess: (result) => setOncePassword(result),
|
||||||
|
onError: (e: Error) => setError(e.message),
|
||||||
|
});
|
||||||
|
|
||||||
const assignRole = useMutation({
|
const assignRole = useMutation({
|
||||||
mutationFn: ({ username, rolename }: { username: string; rolename: string }) =>
|
mutationFn: ({ username, rolename }: { username: string; rolename: string }) =>
|
||||||
assignClientRole(username, rolename),
|
assignClientRole(username, rolename),
|
||||||
@@ -266,6 +273,18 @@ export function ClientsPage() {
|
|||||||
) : (
|
) : (
|
||||||
<button onClick={() => enable.mutate(c.username)}>Enable</button>
|
<button onClick={() => enable.mutate(c.username)}>Enable</button>
|
||||||
)}{" "}
|
)}{" "}
|
||||||
|
<button
|
||||||
|
onClick={() => {
|
||||||
|
if (
|
||||||
|
confirm(
|
||||||
|
`Reset password for ${c.username}? The current password becomes invalid immediately.`,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
resetPassword.mutate(c.username);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Reset password
|
||||||
|
</button>{" "}
|
||||||
<button
|
<button
|
||||||
className="danger"
|
className="danger"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user