-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
88 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import axios from 'axios' | ||
import { AlertStyle, type AlertInterface } from '@userfrosting/sprinkle-core/types' | ||
import { useConfigStore } from '@userfrosting/sprinkle-core/stores' | ||
import type { UserInterface } from '../interfaces' | ||
|
||
// Interfaces | ||
export interface RegisterForm { | ||
first_name: string | ||
last_name: string | ||
email: string | ||
user_name: string | ||
password: string | ||
passwordc: string | ||
locale: string | ||
captcha: string | ||
spiderbro: string | ||
} | ||
|
||
// Variables | ||
const config = useConfigStore() | ||
export const defaultForm: RegisterForm = { | ||
first_name: '', | ||
last_name: '', | ||
email: '', | ||
user_name: '', | ||
password: '', | ||
passwordc: '', | ||
// @ts-ignore | ||
locale: config.config.site.registration.user_defaults.locale, | ||
captcha: '', | ||
spiderbro: 'http://' | ||
} | ||
// @ts-ignore | ||
export const availableLocales = config.config.locales.available | ||
export const captchaUrl = '/account/captcha' // TODO : Add captcha path to config | ||
|
||
// Actions | ||
export async function doRegister(form: RegisterForm) { | ||
return axios | ||
.post<UserInterface>('/account/register', form) | ||
.then((response) => { | ||
return response.data | ||
}) | ||
.catch((err) => { | ||
const error: AlertInterface = { | ||
...{ | ||
description: 'An error as occurred', | ||
style: AlertStyle.Danger, | ||
closeBtn: true | ||
}, | ||
...err.response.data | ||
} | ||
|
||
throw error | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { UserInterface } from '../interfaces'; | ||
export interface RegisterForm { | ||
first_name: string; | ||
last_name: string; | ||
email: string; | ||
user_name: string; | ||
password: string; | ||
passwordc: string; | ||
locale: string; | ||
captcha: string; | ||
spiderbro: string; | ||
} | ||
export declare const defaultForm: RegisterForm; | ||
export declare const availableLocales: any; | ||
export declare const captchaUrl = "/account/captcha"; | ||
export declare function doRegister(form: RegisterForm): Promise<UserInterface>; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.