Add first-login password setup flow

Accounts created by tenant/store onboarding (createtenantuser,
createtenantlocation) have no password set. Previously the login form
treated the backend's "please setup a password" response as a
successful login instead of prompting for one. Now auth.ts recognizes
it (PasswordSetupRequiredError) and LoginView routes to a create-
password step, then signs in immediately with the new password.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Suriya
2026-07-21 16:46:07 +05:30
parent f62668e54e
commit fef75a1cc2
4 changed files with 173 additions and 13 deletions

View File

@@ -54,6 +54,7 @@ import {
getUserById,
createUser,
updateUser,
setUserPassword,
assignRiderToOrders,
CreateUserInput,
createTenantUser,
@@ -892,6 +893,18 @@ export function useLogin() {
});
}
/**
* Set (or reset) a user's login password — used by the login flow's
* create-password step (see PasswordSetupRequiredError in ./auth) for a
* first-time tenant admin or store login.
*/
export function useSetPassword() {
return useMutation({
mutationFn: (input: { userid: number; password: string }) =>
setUserPassword(input.userid, input.password),
});
}
export function useFiestaDeleteLocation() {
const qc = useQueryClient();
return useMutation({