🚧 Add client password reset
This commit is contained in:
@@ -103,6 +103,13 @@ export function ClientsPage() {
|
||||
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({
|
||||
mutationFn: ({ username, rolename }: { username: string; rolename: string }) =>
|
||||
assignClientRole(username, rolename),
|
||||
@@ -266,6 +273,18 @@ export function ClientsPage() {
|
||||
) : (
|
||||
<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
|
||||
className="danger"
|
||||
onClick={() => {
|
||||
|
||||
Reference in New Issue
Block a user