Files
List_ultimate/app/repositories/user.repository.ts
2026-04-07 22:53:49 +02:00

64 lines
1.3 KiB
TypeScript

import type { $Fetch } from 'ofetch';
import type { User, ConfirmResult, LoginResponse } from '~/types/auth'
export default class UserRepository {
private fetcher: $Fetch;
constructor(fetcher: $Fetch) {
this.fetcher = fetcher;
}
async confirm(token: string){
return await this.fetcher<ConfirmResult>('/user/confirm', {
method: 'POST',
body: {
token
}
})
}
async register(email: string, password:string){
return await this.fetcher<LoginResponse>('/auth/register', {
method: 'POST',
body:{
email, password
}
})
}
async emailChange(newEmail: string, locale:string){
return await this.fetcher<ConfirmResult>('/user/email-update/request', {
method: 'POST',
body:{
newEmail, locale
}
})
}
async updateDisplayName(newDisplayName: string){
return await this.fetcher<ConfirmResult>('/user/update', {
method: 'PUT',
body:{
display_name : newDisplayName
}
})
}
async deleteRequest(locale:string){
return await this.fetcher<ConfirmResult>('/user/delete-request', {
method:'DELETE',
body:{
locale
}
})
}
async pwdChallenge(pwd:string){
return await this.fetcher<ConfirmResult>('/user/pwdChallenge', {
method:'POST',
body:{
pwd
}
})
}
}