mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-09-02 15:47:16 +00:00
fix(cloud): launch newly registered accounts through Space (#2499)
* fix(cloud): launch new accounts through Space * style: format Cloud entry URL * fix(cloud): wait for launch workspace projection --------- Co-authored-by: dadachann <185672915+dadachann@users.noreply.github.com>
This commit is contained in:
@@ -1385,12 +1385,18 @@ export class BackendClient extends BaseHttpClient {
|
||||
}
|
||||
|
||||
// ============ Space OAuth API (Redirect Flow) ============
|
||||
public getSpaceAuthorizeUrl(redirectUri: string): Promise<{
|
||||
public getSpaceAuthorizeUrl(
|
||||
redirectUri: string,
|
||||
options?: { cloudEntry?: boolean },
|
||||
): Promise<{
|
||||
authorize_url: string;
|
||||
}> {
|
||||
return this.get(
|
||||
'/api/v1/user/space/authorize-url',
|
||||
{ redirect_uri: redirectUri },
|
||||
{
|
||||
redirect_uri: redirectUri,
|
||||
...(options?.cloudEntry ? { cloud_entry: '1' } : {}),
|
||||
},
|
||||
{ skipWorkspace: true },
|
||||
);
|
||||
}
|
||||
|
||||
@@ -202,7 +202,13 @@ export default function Login() {
|
||||
try {
|
||||
const currentOrigin = window.location.origin;
|
||||
const redirectUri = `${currentOrigin}/auth/space/callback`;
|
||||
const response = await httpClient.getSpaceAuthorizeUrl(redirectUri);
|
||||
const response = await httpClient.getSpaceAuthorizeUrl(redirectUri, {
|
||||
// Cloud Accounts must be launched from Space so a first visit can
|
||||
// lazily create and project the personal Workspace. Invitation login
|
||||
// remains on the OAuth callback path because it targets the invited
|
||||
// Workspace instead.
|
||||
cloudEntry: !getPendingInvitationToken(),
|
||||
});
|
||||
window.location.href = response.authorize_url;
|
||||
} catch {
|
||||
toast.error(t('common.spaceLoginFailed'));
|
||||
|
||||
Reference in New Issue
Block a user