|
1 | 1 | import { ServerRequest, ServerResponse, Server } from "http";
|
2 | 2 | import { parse } from "url";
|
3 |
| -import { join } from "path"; |
4 | 3 | import { isInteractive } from "../helpers";
|
5 | 4 |
|
6 | 5 | export class AuthenticationService implements IAuthenticationService {
|
@@ -32,19 +31,21 @@ export class AuthenticationService implements IAuthenticationService {
|
32 | 31 | let loginUrl: string;
|
33 | 32 | this.localhostServer = this.$httpServer.createServer({
|
34 | 33 | routes: {
|
35 |
| - "/": async (request: ServerRequest, response: ServerResponse) => { |
| 34 | + "/": (request: ServerRequest, response: ServerResponse) => { |
36 | 35 | this.$logger.debug("Login complete: " + request.url);
|
37 | 36 | const parsedUrl = parse(request.url, true);
|
38 | 37 | const loginResponse = parsedUrl.query.response;
|
39 | 38 | if (loginResponse) {
|
40 |
| - await this.serveLoginFile("end.html")(request, response); |
| 39 | + response.statusCode = 302; |
| 40 | + response.setHeader("Location", parsedUrl.query.loginCompleteUrl); |
41 | 41 | this.killLocalhostServer();
|
42 | 42 |
|
43 | 43 | isResolved = true;
|
44 | 44 |
|
45 | 45 | const decodedResponse = new Buffer(loginResponse, "base64").toString();
|
46 | 46 | this.rejectLoginPromiseAction = null;
|
47 | 47 | authCompleteResolveAction(decodedResponse);
|
| 48 | + response.end(); |
48 | 49 | } else {
|
49 | 50 | this.$httpServer.redirect(response, loginUrl);
|
50 | 51 | }
|
@@ -172,10 +173,6 @@ export class AuthenticationService implements IAuthenticationService {
|
172 | 173 | return tokenState;
|
173 | 174 | }
|
174 | 175 |
|
175 |
| - private serveLoginFile(relPath: string): (request: ServerRequest, response: ServerResponse) => Promise<void> { |
176 |
| - return this.$httpServer.serveFile(join(__dirname, "..", "..", "resources", "login", relPath)); |
177 |
| - } |
178 |
| - |
179 | 176 | private killLocalhostServer(): void {
|
180 | 177 | this.localhostServer.close();
|
181 | 178 | this.localhostServer = null;
|
|
0 commit comments