perm guard
deploy to danak / build_and_deploy (push) Has been cancelled

This commit is contained in:
2026-07-24 13:23:11 +03:30
parent 8563508674
commit 7d4e2865bb
5 changed files with 194 additions and 57 deletions
+6 -3
View File
@@ -11,9 +11,11 @@ import { useLoginWithOtp, useOtpVerify } from '../hooks/useAuthData'
import { extractErrorMessage, setRefreshToken } from '../../../config/func'
import { setToken } from '../../../config/func'
import { toast } from '@/shared/toast'
import { Paths } from '@/config/Paths'
import { useSessionAuth } from '@/config/sessionAuth'
import { appNavigate } from '@/config/navigation'
import { getDefaultAdminPath } from '@/config/permissions'
import type { BaseResponse } from '@/shared/types/Types'
import type { OtpVerifyResponseType } from '../types/AuthTypes'
const LoginStep2: FC = () => {
@@ -39,11 +41,12 @@ const LoginStep2: FC = () => {
otp: values.otp
}
otpVerify.mutate(params, {
onSuccess(data) {
onSuccess(data: BaseResponse<OtpVerifyResponseType>) {
setToken(data?.data?.tokens?.accessToken?.token)
setRefreshToken(data?.data?.tokens?.refreshToken?.token)
useSessionAuth.getState().setAuthenticated(true)
appNavigate(Paths.home, { replace: true })
const permissions = data?.data?.admin?.permissions ?? []
appNavigate(getDefaultAdminPath(permissions), { replace: true })
},
onError(error) {
toast(extractErrorMessage(error), 'error')
+16
View File
@@ -33,6 +33,22 @@ export type OtpVerifyType = {
otp: string;
};
export type AdminLoginResponseType = {
firstName?: string;
lastName?: string;
phone: string;
role: string;
permissions: string[];
};
export type OtpVerifyResponseType = {
tokens: {
accessToken: { token: string };
refreshToken: { token: string };
};
admin: AdminLoginResponseType;
};
export type CheckHasAccountType = {
email: string;
};