Send preferred authentication method along with user data when creating new account

This commit is contained in:
silverpill 2023-04-18 21:48:13 +00:00
parent 3fbe2dce58
commit 23ea751341
3 changed files with 13 additions and 3 deletions

View file

@ -13,6 +13,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Content warnings. - Content warnings.
- List enabled authentication methods in "Settings". - List enabled authentication methods in "Settings".
### Changed
- Send preferred authentication method along with user data when creating new account.
### Fixed ### Fixed
- Fix update of unread notification counter. - Fix update of unread notification counter.

View file

@ -145,11 +145,17 @@ interface UserCreateForm {
invite_code: string | null; invite_code: string | null;
} }
export async function createUser(userData: UserCreateForm): Promise<User> { export async function createUser(
loginType: "password" | "eip4361",
userData: UserCreateForm,
): Promise<User> {
const url = `${BACKEND_URL}/api/v1/accounts` const url = `${BACKEND_URL}/api/v1/accounts`
const response = await http(url, { const response = await http(url, {
method: "POST", method: "POST",
json: userData, json: {
authentication_method: loginType,
...userData,
},
}) })
const data = await response.json() const data = await response.json()
if (response.status !== 201) { if (response.status !== 201) {

View file

@ -217,7 +217,7 @@ async function register() {
let user let user
let authToken let authToken
try { try {
user = await createUser(userData) user = await createUser(loginType, userData)
authToken = await getAccessToken(loginType, loginData) authToken = await getAccessToken(loginType, loginData)
} catch (error: any) { } catch (error: any) {
isLoading = false isLoading = false