feat: init new auth

This commit is contained in:
swve 2024-05-25 14:56:28 +02:00
parent f838a8512c
commit 1708b36818
34 changed files with 1853 additions and 3613 deletions

View file

@ -1,19 +1,27 @@
import { getAPIUrl } from '@services/config/config'
import { RequestBody, getResponseMetadata } from '@services/utils/ts/requests'
import {
RequestBody,
RequestBodyWithAuthHeader,
getResponseMetadata,
} from '@services/utils/ts/requests'
export async function createInviteCode(org_id: any) {
export async function createInviteCode(org_id: any, access_token: any) {
const result = await fetch(
`${getAPIUrl()}orgs/${org_id}/invites`,
RequestBody('POST', null, null)
RequestBodyWithAuthHeader('POST', null, null, access_token)
)
const res = await getResponseMetadata(result)
return res
}
export async function createInviteCodeWithUserGroup(org_id: any, usergroup_id: number) {
export async function createInviteCodeWithUserGroup(
org_id: any,
usergroup_id: number,
access_token: any
) {
const result = await fetch(
`${getAPIUrl()}orgs/${org_id}/invites_with_usergroups?usergroup_id=${usergroup_id}`,
RequestBody('POST', null, null)
RequestBodyWithAuthHeader('POST', null, null, access_token)
)
const res = await getResponseMetadata(result)
return res
@ -21,11 +29,12 @@ export async function createInviteCodeWithUserGroup(org_id: any, usergroup_id: n
export async function deleteInviteCode(
org_id: any,
org_invite_code_uuid: string
org_invite_code_uuid: string,
access_token: any
) {
const result = await fetch(
`${getAPIUrl()}orgs/${org_id}/invites/${org_invite_code_uuid}`,
RequestBody('DELETE', null, null)
RequestBodyWithAuthHeader('DELETE', null, null, access_token)
)
const res = await getResponseMetadata(result)
return res
@ -33,20 +42,25 @@ export async function deleteInviteCode(
export async function changeSignupMechanism(
org_id: any,
signup_mechanism: string
signup_mechanism: string,
access_token: any
) {
const result = await fetch(
`${getAPIUrl()}orgs/${org_id}/signup_mechanism?signup_mechanism=${signup_mechanism}`,
RequestBody('PUT', null, null)
RequestBodyWithAuthHeader('PUT', null, null, access_token)
)
const res = await getResponseMetadata(result)
return res
}
export async function validateInviteCode(org_id: any, invite_code: string) {
export async function validateInviteCode(
org_id: any,
invite_code: string,
access_token: any
) {
const result = await fetch(
`${getAPIUrl()}orgs/${org_id}/invites/code/${invite_code}`,
RequestBody('GET', null, null)
RequestBodyWithAuthHeader('GET', null, null, access_token)
)
const res = await getResponseMetadata(result)
return res
@ -55,11 +69,12 @@ export async function validateInviteCode(org_id: any, invite_code: string) {
export async function inviteBatchUsers(
org_id: any,
emails: string,
invite_code_uuid: string
invite_code_uuid: string,
access_token: any
) {
const result = await fetch(
`${getAPIUrl()}orgs/${org_id}/invites/users/batch?emails=${emails}&invite_code_uuid=${invite_code_uuid}`,
RequestBody('POST', null, null)
RequestBodyWithAuthHeader('POST', null, null, access_token)
)
const res = await getResponseMetadata(result)
return res