Skip to content

Commit

Permalink
fix(nx-cloud): update check for access token
Browse files Browse the repository at this point in the history
  • Loading branch information
lourw committed Sep 12, 2024
1 parent 7534904 commit 0cd20ea
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 4 additions & 0 deletions packages/nx/src/nx-cloud/utilities/get-cloud-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ export function getCloudUrl() {
export function removeTrailingSlash(apiUrl: string) {
return apiUrl[apiUrl.length - 1] === '/' ? apiUrl.slice(0, -1) : apiUrl;
}

export function isNxCloudId(token: string): boolean {
return token.length === 24;
}
13 changes: 7 additions & 6 deletions packages/nx/src/nx-cloud/utilities/is-workspace-claimed.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { getCloudUrl } from './get-cloud-options';
import { getCloudUrl, isNxCloudId } from './get-cloud-options';

export async function isWorkspaceClaimed(nxCloudAccessToken) {
if (!nxCloudAccessToken) return false;
export async function isWorkspaceClaimed(accessToken: string) {
if (!accessToken) return false;

const apiUrl = getCloudUrl();
try {
const requestData = isNxCloudId(accessToken)
? { nxCloudId: accessToken }
: { nxCloudAccessToken: accessToken };
const response = await require('axios').post(
`${apiUrl}/nx-cloud/is-workspace-claimed`,
{
nxCloudAccessToken,
}
requestData
);

if (response.data.message) {
Expand Down

0 comments on commit 0cd20ea

Please sign in to comment.