2019-09-23 19:00:28 +00:00
|
|
|
import request from '@/utils/request'
|
|
|
|
import { getToken } from '@/utils/auth'
|
|
|
|
import { baseName } from './utils'
|
|
|
|
|
|
|
|
export async function generateInviteToken(max_use, expires_at, authHost, token) {
|
|
|
|
return await request({
|
|
|
|
baseURL: baseName(authHost),
|
|
|
|
url: `/api/pleroma/admin/users/invite_token`,
|
|
|
|
method: 'post',
|
|
|
|
headers: authHeaders(token),
|
|
|
|
data: expires_at && expires_at.length > 0 ? { max_use, expires_at } : { max_use }
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function inviteViaEmail(email, name, authHost, token) {
|
2020-03-18 21:03:33 +00:00
|
|
|
const data = name.length > 0 ? { email, name } : { email }
|
2019-09-23 19:00:28 +00:00
|
|
|
return await request({
|
|
|
|
baseURL: baseName(authHost),
|
2020-03-18 21:03:33 +00:00
|
|
|
url: '/api/pleroma/admin/users/email_invite',
|
2019-09-23 19:00:28 +00:00
|
|
|
method: 'post',
|
2020-03-18 21:03:33 +00:00
|
|
|
headers: authHeaders(token),
|
|
|
|
data
|
2019-09-23 19:00:28 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function listInviteTokens(authHost, token) {
|
|
|
|
return await request({
|
|
|
|
baseURL: baseName(authHost),
|
|
|
|
url: `/api/pleroma/admin/users/invites`,
|
|
|
|
method: 'get',
|
|
|
|
headers: authHeaders(token)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function revokeToken(tokenToRevoke, authHost, token) {
|
|
|
|
return await request({
|
|
|
|
baseURL: baseName(authHost),
|
|
|
|
url: `/api/pleroma/admin/users/revoke_invite`,
|
|
|
|
method: 'post',
|
|
|
|
headers: authHeaders(token),
|
|
|
|
data: { token: tokenToRevoke }
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
const authHeaders = (token) => token ? { 'Authorization': `Bearer ${getToken()}` } : {}
|