fix teacher, parent and admin pages
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* Password reset / initial set-password flows (legacy CI `user/*` auth views).
|
||||
* Backend expected under `/api/v1/auth/...`.
|
||||
*/
|
||||
import { apiFetch } from './http'
|
||||
|
||||
export async function requestForgotPassword(email: string): Promise<{ ok?: boolean; message?: string }> {
|
||||
return apiFetch('/api/v1/auth/forgot-password', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ email: email.trim() }),
|
||||
})
|
||||
}
|
||||
|
||||
export async function submitPasswordReset(payload: {
|
||||
token: string
|
||||
password: string
|
||||
pass_confirm: string
|
||||
}): Promise<{ ok?: boolean; message?: string }> {
|
||||
return apiFetch('/api/v1/auth/reset-password', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
}
|
||||
|
||||
export async function submitSetPassword(payload: {
|
||||
user_id: number | string
|
||||
token: string
|
||||
password: string
|
||||
password_confirm: string
|
||||
}): Promise<{ ok?: boolean; message?: string }> {
|
||||
return apiFetch('/api/v1/auth/set-password', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
}
|
||||
|
||||
export async function submitAuthorizedUserPassword(
|
||||
userId: number | string,
|
||||
payload: { token: string; password: string; password_confirm: string },
|
||||
): Promise<{ ok?: boolean; message?: string }> {
|
||||
return apiFetch(`/api/v1/auth/set-authorized-user-password/${encodeURIComponent(String(userId))}`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user