-
-
Notifications
You must be signed in to change notification settings - Fork 820
Expand file tree
/
Copy pathtenant.ts
More file actions
138 lines (113 loc) · 4.31 KB
/
Copy pathtenant.ts
File metadata and controls
138 lines (113 loc) · 4.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import { http, Result } from "@fider/services/http"
import { UserRole, OAuthConfig, ImageUpload, EmailVerificationKind } from "@fider/models"
import { PrivacySettingsPageState } from "@fider/pages/Administration/pages/PrivacySettings.page"
export interface CheckAvailabilityResponse {
message: string
}
export interface CreateTenantRequest {
legalAgreement: boolean
tenantName: string
subdomain?: string
name?: string
token?: string
email?: string
}
export interface CreateTenantResponse {
token?: string
}
export const createTenant = async (request: CreateTenantRequest): Promise<Result<CreateTenantResponse>> => {
return await http.post<CreateTenantResponse>("/_api/tenants", request)
}
export interface UpdateTenantSettingsRequest {
logo?: ImageUpload
title: string
invitation: string
welcomeMessage: string
welcomeHeader: string
descriptionTemplate: string
cname: string
locale: string
}
export const updateTenantSettings = async (request: UpdateTenantSettingsRequest): Promise<Result> => {
return await http.post("/_api/admin/settings/general", request)
}
export const updateTenantAdvancedSettings = async (customCSS: string, allowedSchemes: string): Promise<Result> => {
return await http.post("/_api/admin/settings/advanced", { customCSS, allowedSchemes })
}
export const updateTenantPrivacy = async (request: PrivacySettingsPageState): Promise<Result> => {
return await http.post("/_api/admin/settings/privacy", request)
}
export const updateTenantEmailAuthAllowed = async (isEmailAuthAllowed: boolean): Promise<Result> => {
return await http.post("/_api/admin/settings/emailauth", {
isEmailAuthAllowed,
})
}
export const checkAvailability = async (subdomain: string): Promise<Result<CheckAvailabilityResponse>> => {
return await http.get<CheckAvailabilityResponse>(`/_api/tenants/${subdomain}/availability`)
}
export const signIn = async (email: string): Promise<Result> => {
return await http.post("/_api/signin", { email })
}
export const signInNewUser = async (email: string, name: string): Promise<Result> => {
return await http.post("/_api/signin/newuser", { email, name })
}
export const verifySignInCode = async (email: string, code: string): Promise<Result> => {
return await http.post("/_api/signin/verify", { email, code })
}
export const resendSignInCode = async (email: string): Promise<Result> => {
return await http.post("/_api/signin/resend", { email })
}
export const completeProfile = async (kind: EmailVerificationKind, key: string, name: string): Promise<Result> => {
return await http.post("/_api/signin/complete", {
kind,
key,
name,
})
}
export const changeUserRole = async (userID: number, role: UserRole): Promise<Result> => {
return await http.post(`/_api/admin/roles/${role}/users`, {
userID,
})
}
export const blockUser = async (userID: number): Promise<Result> => {
return await http.put(`/_api/admin/users/${userID}/block`)
}
export const unblockUser = async (userID: number): Promise<Result> => {
return await http.delete(`/_api/admin/users/${userID}/block`)
}
export const trustUser = async (userID: number): Promise<Result> => {
return await http.put(`/_api/admin/users/${userID}/trust`)
}
export const untrustUser = async (userID: number): Promise<Result> => {
return await http.delete(`/_api/admin/users/${userID}/trust`)
}
export const getOAuthConfig = async (provider: string): Promise<Result<OAuthConfig>> => {
return await http.get<OAuthConfig>(`/_api/admin/oauth/${provider}`)
}
export interface CreateEditOAuthConfigRequest {
provider: string
status: number
displayName: string
clientID: string
clientSecret: string
authorizeURL: string
tokenURL: string
scope: string
profileURL: string
jsonUserIDPath: string
jsonUserNamePath: string
jsonUserEmailPath: string
jsonUserRolesPath: string
allowedRoles: string
logo?: ImageUpload
isTrusted: boolean
}
export const saveOAuthConfig = async (request: CreateEditOAuthConfigRequest): Promise<Result> => {
return await http.post("/_api/admin/oauth", request)
}
export const setSystemProviderStatus = async (provider: string, isEnabled: boolean): Promise<Result> => {
return await http.post(`/_api/admin/oauth/${provider}/status`, { provider, isEnabled })
}
export const resendSignUpEmail = async (): Promise<Result> => {
return await http.post("/_api/signup/resend", {})
}