fix some for iam

This commit is contained in:
Montech
2026-10-07 16:45:36 +03:30
parent a72fa607a5
commit 5223de313a
25 changed files with 823 additions and 38 deletions
@@ -159,7 +159,8 @@ const sendPhone = async () => {
const sendToken = async (otpCode: string) => {
try {
body.loading = true
const { token, customer } = await api.verifyOtp(String(formModel.username ?? ''), otpCode)
const verified = await api.verifyOtp(String(formModel.username ?? ''), otpCode)
const { token, customer } = verified
session.login(token, customer.id, customer.mobile)
// D21 — ask the server which kind of principal this token is, so the
// expert-only entries appear for a sales expert. Failure is non-fatal:
@@ -171,6 +172,10 @@ const sendToken = async (otpCode: string) => {
} catch {
session.setSalesExpert(false)
}
if (verified.iamBootstrapUrl) {
window.location.assign(verified.iamBootstrapUrl)
return
}
const redirect = typeof route.query.redirect === 'string' ? route.query.redirect : undefined
await router.push(redirect ?? { name: 'home' })
toast.success('با موفقیت وارد شدید')