Skip to content

Commit b0803d4

Browse files
committed
[dashboard] Accelerate authorization redirect in create workspace page
1 parent d090d2c commit b0803d4

File tree

1 file changed

+3
-20
lines changed

1 file changed

+3
-20
lines changed

components/dashboard/src/start/CreateWorkspace.tsx

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,8 @@ export default class CreateWorkspace extends React.Component<CreateWorkspaceProp
7676
</div>;
7777
break;
7878
case ErrorCodes.NOT_AUTHENTICATED:
79-
const authorizeUrl = gitpodHostUrl.withApi({
80-
pathname: '/authorize',
81-
search: `returnTo=${encodeURIComponent(window.location.toString())}&host=${error.data.host}&scopes=${error.data.scopes.join(',')}`
82-
}).toString();
83-
window.location.href = authorizeUrl;
84-
statusMessage = <div className="mt-2 flex flex-col space-y-8">
85-
<p className="text-base w-96">Redirecting to authorize with {error.data.host}</p>
86-
<a href={authorizeUrl}><button className="secondary">Authorize with {error.data.host}</button></a>
87-
</div>;
88-
break;
79+
const authorizeURL = `/api/authorize?returnTo=${encodeURIComponent(window.location.toString())}&host=${error.data.host}&scopes=${error.data.scopes.join(',')}`;
80+
return <Redirect push to={authorizeURL}/>;
8981
case ErrorCodes.USER_BLOCKED:
9082
return <Redirect to="/blocked"/>;
9183
case ErrorCodes.NOT_FOUND:
@@ -206,12 +198,6 @@ function RepositoryNotFoundView(p: { error: StartWorkspaceError }) {
206198
(async () => {
207199
const service = getGitpodService();
208200
const { host, owner, repoName, userIsOwner, userScopes, lastUpdate } = p.error.data;
209-
console.log('host', host);
210-
console.log('owner', owner);
211-
console.log('repoName', repoName);
212-
console.log('userIsOwner', userIsOwner);
213-
console.log('userScopes', userScopes);
214-
console.log('lastUpdate', lastUpdate);
215201

216202
if ((await service.server.mayAccessPrivateRepo()) === false) {
217203
setStatusMessage(<LimitReachedPrivateRepoModal/>);
@@ -227,10 +213,7 @@ function RepositoryNotFoundView(p: { error: StartWorkspaceError }) {
227213

228214
// TODO: this should be aware of already granted permissions
229215
const missingScope = authProvider.host === 'github.com' ? 'repo' : 'read_repository';
230-
const authorizeURL = gitpodHostUrl.withApi({
231-
pathname: '/authorize',
232-
search: `returnTo=${encodeURIComponent(window.location.toString())}&host=${host}&scopes=${missingScope}`
233-
}).toString();
216+
const authorizeURL = `/api/authorize?returnTo=${encodeURIComponent(window.location.toString())}&host=${host}&scopes=${missingScope}`;
234217

235218
if (!userScopes.includes(missingScope)) {
236219
setStatusMessage(<div className="mt-2 flex flex-col space-y-8">

0 commit comments

Comments
 (0)