mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-07 10:17:42 +02:00
Fix ai bot workspace assign (#7116)
Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
@@ -13,7 +13,15 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import { type BaseWorkspaceInfo, type Data, type Version, BackupStatus } from '@hcengineering/core'
|
||||
import {
|
||||
type BaseWorkspaceInfo,
|
||||
type Data,
|
||||
type Version,
|
||||
BackupStatus,
|
||||
AccountRole,
|
||||
Ref,
|
||||
Doc
|
||||
} from '@hcengineering/core'
|
||||
import { getMetadata, PlatformError, unknownError } from '@hcengineering/platform'
|
||||
|
||||
import plugin from './plugin'
|
||||
@@ -296,3 +304,52 @@ function getAccoutsUrlOrFail (): string {
|
||||
}
|
||||
return accountsUrl
|
||||
}
|
||||
|
||||
export async function assignWorkspace (
|
||||
token: string,
|
||||
email: string,
|
||||
workspace: string,
|
||||
role: AccountRole = AccountRole.User,
|
||||
personId?: Ref<Doc>,
|
||||
shouldReplaceAccount = false,
|
||||
personAccountId?: Ref<Doc>
|
||||
): Promise<WorkspaceLoginInfo> {
|
||||
const accountsUrl = getAccoutsUrlOrFail()
|
||||
const res = await (
|
||||
await fetch(accountsUrl, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
method: 'assignWorkspace',
|
||||
params: [token, email, workspace, role, personId, shouldReplaceAccount, undefined, personAccountId]
|
||||
})
|
||||
})
|
||||
).json()
|
||||
|
||||
return res.result as WorkspaceLoginInfo
|
||||
}
|
||||
|
||||
export async function createAccount (
|
||||
email: string,
|
||||
password: string,
|
||||
firstName: string,
|
||||
lastName: string
|
||||
): Promise<WorkspaceLoginInfo> {
|
||||
const accountsUrl = getAccoutsUrlOrFail()
|
||||
const workspace = await (
|
||||
await fetch(accountsUrl, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
method: 'createAccount',
|
||||
params: [email, password, firstName, lastName]
|
||||
})
|
||||
})
|
||||
).json()
|
||||
|
||||
return workspace.result as WorkspaceLoginInfo
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user