Skip to content
This repository was archived by the owner on Dec 12, 2022. It is now read-only.

Commit abb5240

Browse files
Move the login complete page in the server
Since the logout complete page is in our server we should move the login complete page there too. This requires to get new parameter from the query string of the request to the localhost - loginCompleteUrl. Then we just redirect to it instead of serving local file.
1 parent e9f1652 commit abb5240

File tree

2 files changed

+4
-78
lines changed

2 files changed

+4
-78
lines changed

lib/services/authentication-service.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { ServerRequest, ServerResponse, Server } from "http";
22
import { parse } from "url";
3-
import { join } from "path";
43
import { isInteractive } from "../helpers";
54

65
export class AuthenticationService implements IAuthenticationService {
@@ -32,19 +31,21 @@ export class AuthenticationService implements IAuthenticationService {
3231
let loginUrl: string;
3332
this.localhostServer = this.$httpServer.createServer({
3433
routes: {
35-
"/": async (request: ServerRequest, response: ServerResponse) => {
34+
"/": (request: ServerRequest, response: ServerResponse) => {
3635
this.$logger.debug("Login complete: " + request.url);
3736
const parsedUrl = parse(request.url, true);
3837
const loginResponse = parsedUrl.query.response;
3938
if (loginResponse) {
40-
await this.serveLoginFile("end.html")(request, response);
39+
response.statusCode = 302;
40+
response.setHeader("Location", parsedUrl.query.loginCompleteUrl);
4141
this.killLocalhostServer();
4242

4343
isResolved = true;
4444

4545
const decodedResponse = new Buffer(loginResponse, "base64").toString();
4646
this.rejectLoginPromiseAction = null;
4747
authCompleteResolveAction(decodedResponse);
48+
response.end();
4849
} else {
4950
this.$httpServer.redirect(response, loginUrl);
5051
}
@@ -172,10 +173,6 @@ export class AuthenticationService implements IAuthenticationService {
172173
return tokenState;
173174
}
174175

175-
private serveLoginFile(relPath: string): (request: ServerRequest, response: ServerResponse) => Promise<void> {
176-
return this.$httpServer.serveFile(join(__dirname, "..", "..", "resources", "login", relPath));
177-
}
178-
179176
private killLocalhostServer(): void {
180177
this.localhostServer.close();
181178
this.localhostServer = null;

resources/login/end.html

Lines changed: 0 additions & 71 deletions
This file was deleted.

0 commit comments

Comments
 (0)