mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-19 17:55:17 -04:00
Split user.ts into auth.ts and me.ts (#113)
Split user.ts into auth.ts and me.ts
This commit is contained in:
parent
1fa8c8ac53
commit
db5bec7000
9 changed files with 53 additions and 51 deletions
40
src/api/auth.ts
Normal file
40
src/api/auth.ts
Normal file
|
@ -0,0 +1,40 @@
|
|||
import { expectResponseCode, getBackendUrl } from '../utils/apiUtils'
|
||||
import { defaultFetchConfig } from './default'
|
||||
|
||||
export const doEmailLogin = async (email: string, password: string): Promise<void> => {
|
||||
const response = await fetch(getBackendUrl() + '/auth/email', {
|
||||
...defaultFetchConfig,
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
email: email,
|
||||
password: password
|
||||
})
|
||||
})
|
||||
|
||||
expectResponseCode(response)
|
||||
}
|
||||
|
||||
export const doLdapLogin = async (username: string, password: string): Promise<void> => {
|
||||
const response = await fetch(getBackendUrl() + '/auth/ldap', {
|
||||
...defaultFetchConfig,
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
username: username,
|
||||
password: password
|
||||
})
|
||||
})
|
||||
|
||||
expectResponseCode(response)
|
||||
}
|
||||
|
||||
export const doOpenIdLogin = async (openId: string): Promise<void> => {
|
||||
const response = await fetch(getBackendUrl() + '/auth/openid', {
|
||||
...defaultFetchConfig,
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
openId: openId
|
||||
})
|
||||
})
|
||||
|
||||
expectResponseCode(response)
|
||||
}
|
|
@ -15,44 +15,6 @@ export interface meResponse {
|
|||
provider: LoginProvider
|
||||
}
|
||||
|
||||
export const doEmailLogin = async (email: string, password: string): Promise<void> => {
|
||||
const response = await fetch(getBackendUrl() + '/auth/email', {
|
||||
...defaultFetchConfig,
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
email: email,
|
||||
password: password
|
||||
})
|
||||
})
|
||||
|
||||
expectResponseCode(response)
|
||||
}
|
||||
|
||||
export const doLdapLogin = async (username: string, password: string): Promise<void> => {
|
||||
const response = await fetch(getBackendUrl() + '/auth/ldap', {
|
||||
...defaultFetchConfig,
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
username: username,
|
||||
password: password
|
||||
})
|
||||
})
|
||||
|
||||
expectResponseCode(response)
|
||||
}
|
||||
|
||||
export const doOpenIdLogin = async (openId: string): Promise<void> => {
|
||||
const response = await fetch(getBackendUrl() + '/auth/openid', {
|
||||
...defaultFetchConfig,
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
openId: openId
|
||||
})
|
||||
})
|
||||
|
||||
expectResponseCode(response)
|
||||
}
|
||||
|
||||
export const updateDisplayName = async (displayName: string): Promise<void> => {
|
||||
const response = await fetch(getBackendUrl() + '/me', {
|
||||
...defaultFetchConfig,
|
Loading…
Add table
Add a link
Reference in a new issue