mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-05 17:27:41 +02:00
QFix: Pass extra token details in selectWorkspace (#8010)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// Copyright © 2025 Hardcore Engineering Inc.
|
||||
//
|
||||
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License. You may
|
||||
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
//
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
const ADMIN_EMAILS = new Set(process.env.ADMIN_EMAILS?.split(',') ?? [])
|
||||
|
||||
export function isAdminEmail (email: string): boolean {
|
||||
return ADMIN_EMAILS.has(email.trim())
|
||||
}
|
||||
@@ -91,12 +91,11 @@ import {
|
||||
wrap,
|
||||
verifyAllowedServices
|
||||
} from './utils'
|
||||
import { isAdminEmail } from './admin'
|
||||
|
||||
// Move to config?
|
||||
const processingTimeoutMs = 30 * 1000
|
||||
|
||||
const ADMIN_EMAILS = new Set(process.env.ADMIN_EMAILS?.split(',') ?? [])
|
||||
|
||||
/* =================================== */
|
||||
/* ============OPERATIONS============= */
|
||||
/* =================================== */
|
||||
@@ -132,12 +131,12 @@ export async function login (
|
||||
|
||||
const isConfirmed = emailSocialId.verifiedOn != null
|
||||
|
||||
const isAdmin: Record<string, string> = ADMIN_EMAILS.has(email.trim()) ? { admin: 'true' } : {}
|
||||
ctx.info('Login succeeded', { email, normalizedEmail, isConfirmed, emailSocialId, ...isAdmin })
|
||||
const extraToken: Record<string, string> = isAdminEmail(email) ? { admin: 'true' } : {}
|
||||
ctx.info('Login succeeded', { email, normalizedEmail, isConfirmed, emailSocialId, ...extraToken })
|
||||
|
||||
return {
|
||||
account: existingAccount.uuid,
|
||||
token: isConfirmed ? generateToken(existingAccount.uuid, undefined, isAdmin) : undefined
|
||||
token: isConfirmed ? generateToken(existingAccount.uuid, undefined, extraToken) : undefined
|
||||
}
|
||||
} catch (err: any) {
|
||||
Analytics.handleError(err)
|
||||
|
||||
@@ -536,7 +536,7 @@ export async function selectWorkspace (
|
||||
if (accountUuid === systemAccountUuid) {
|
||||
return {
|
||||
account: accountUuid,
|
||||
token: generateToken(accountUuid, workspace.uuid),
|
||||
token: generateToken(accountUuid, workspace.uuid, extra),
|
||||
endpoint: getEndpoint(ctx, workspace.uuid, workspace.region, getKind(workspace.region)),
|
||||
workspace: workspace.uuid,
|
||||
workspaceUrl: workspace.url,
|
||||
@@ -563,7 +563,7 @@ export async function selectWorkspace (
|
||||
|
||||
return {
|
||||
account: accountUuid,
|
||||
token: generateToken(accountUuid, workspace.uuid),
|
||||
token: generateToken(accountUuid, workspace.uuid, extra),
|
||||
endpoint: getEndpoint(ctx, workspace.uuid, workspace.region, getKind(workspace.region)),
|
||||
workspace: workspace.uuid,
|
||||
workspaceUrl: workspace.url,
|
||||
|
||||
Reference in New Issue
Block a user