From 8f89f0600d0435ab849d4f7bbc4042c52c16851a Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sun, 12 Apr 2020 03:31:47 +0200 Subject: [PATCH] Putting the login component outsite of the SPA --- src/app/auth/auth-routing.module.ts | 2 - src/app/auth/auth.module.ts | 14 +--- src/app/auth/login/login.component.html | 93 ------------------------- src/app/auth/login/login.component.scss | 0 src/app/auth/login/login.component.ts | 63 ----------------- src/styles.scss | 1 - static/iconfont/material-icons.css | 56 +++++++-------- 7 files changed, 31 insertions(+), 198 deletions(-) delete mode 100644 src/app/auth/login/login.component.html delete mode 100644 src/app/auth/login/login.component.scss delete mode 100644 src/app/auth/login/login.component.ts diff --git a/src/app/auth/auth-routing.module.ts b/src/app/auth/auth-routing.module.ts index 20253f5d..fd7f540e 100644 --- a/src/app/auth/auth-routing.module.ts +++ b/src/app/auth/auth-routing.module.ts @@ -1,12 +1,10 @@ import {NgModule} from '@angular/core'; import {RouterModule, Routes} from "@angular/router"; import {UnauthorizedComponent} from "./unauthorized/unauthorized.component"; -import {LoginComponent} from "./login/login.component"; import {LogoutComponent} from "./logout/logout.component"; import {AutologinComponent} from "./autologin/autologin.component"; const routes: Routes = [ - {path: "login", component: LoginComponent}, {path: "logout", component: LogoutComponent}, {path: "autologin", component: AutologinComponent}, {path: "unauthorized", component: UnauthorizedComponent}, diff --git a/src/app/auth/auth.module.ts b/src/app/auth/auth.module.ts index 62484903..314b0c06 100644 --- a/src/app/auth/auth.module.ts +++ b/src/app/auth/auth.module.ts @@ -5,7 +5,6 @@ import {AuthPipe} from "./misc/auth.pipe"; import {AutologinComponent} from "./autologin/autologin.component"; import {UnauthorizedComponent} from "./unauthorized/unauthorized.component"; import {LogoutComponent} from "./logout/logout.component"; -import {LoginComponent} from "./login/login.component"; import {ConfigResult, OidcConfigService, OidcSecurityService, OpenIdConfiguration, AuthModule as OidcModule} from "angular-auth-oidc-client"; import {HTTP_INTERCEPTORS, HttpClient, HttpClientModule} from "@angular/common/http"; import {AuthGuard} from "./misc/authenticated-guard.service"; @@ -13,14 +12,8 @@ import {AuthorizerInterceptor} from "./misc/authorizer-interceptor.service"; import {MatFormFieldModule} from "@angular/material/form-field"; import {MatIconModule} from "@angular/material/icon"; import {MatInputModule} from "@angular/material/input"; -import {AppComponent} from "../app.component"; import {MatDialogModule} from "@angular/material/dialog"; import {MatButtonModule} from "@angular/material/button"; -import {BrowserModule} from "@angular/platform-browser"; -import {AppRoutingModule} from "../app-routing.module"; -import {BrowserAnimationsModule} from "@angular/platform-browser/animations"; -import {MatSnackBarModule} from "@angular/material/snack-bar"; -import {MatProgressBarModule} from "@angular/material/progress-bar"; import {MatSelectModule} from "@angular/material/select"; import {MatMenuModule} from "@angular/material/menu"; import {MatSliderModule} from "@angular/material/slider"; @@ -42,8 +35,7 @@ export function loadConfig(oidcConfigService: OidcConfigService) AuthPipe, AccountComponent, UnauthorizedComponent, - LogoutComponent, - LoginComponent, + LogoutComponent ], imports: [ CommonModule, @@ -95,8 +87,8 @@ export class AuthModule client_id: 'kyoo.webapp', response_type: "code", trigger_authorization_result_event: true, - scope: "openid profile offline_access kyoo.read kyoo.play", - silent_renew: false, + scope: "openid profile", + silent_renew: true, silent_renew_url: "/silent", use_refresh_token: false, start_checksession: true, diff --git a/src/app/auth/login/login.component.html b/src/app/auth/login/login.component.html deleted file mode 100644 index 3bb132b6..00000000 --- a/src/app/auth/login/login.component.html +++ /dev/null @@ -1,93 +0,0 @@ -
- - - -
-
- - - Username - - - An username is required - - -
-
- - Password - - - - A password is required - - - Error: {{loginPassword.getError("passwordError")["error"]}} - - -
- Stay logged in -
-
- - {{item.description}} - -
-
- -
-
-
- -
-
- - - Email - - - An email is required - - - Please enter a valid email - - -
-
- - Username - - - An username is required - - -
-
- - Password - - - - A password is required - - - Error: {{signinPassword.getError("passwordError")["error"]}} - - - - - {{item.description}} - -
-
- -
-
-
-
-
-
\ No newline at end of file diff --git a/src/app/auth/login/login.component.scss b/src/app/auth/login/login.component.scss deleted file mode 100644 index e69de29b..00000000 diff --git a/src/app/auth/login/login.component.ts b/src/app/auth/login/login.component.ts deleted file mode 100644 index 04ae4068..00000000 --- a/src/app/auth/login/login.component.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { Component } from '@angular/core'; -import {ActivatedRoute, Router} from "@angular/router"; -import {catchError} from "rxjs/operators"; -import {EMPTY} from "rxjs"; -import {HttpClient} from "@angular/common/http"; - -@Component({ - selector: 'app-login', - templateUrl: './login.component.html', - styleUrls: ['./login.component.scss'] -}) -export class LoginComponent -{ - loginInformation: {username: string, password: string, stayLoggedIn: boolean} = {username: "", password: "", stayLoggedIn: false}; - signinInformation: {email: string, username: string, password: string} = {email: "", username: "", password: ""}; - hidePassword: boolean = true; - redirectURI: string; - - loginErrors: [{code: string, description: string}]; - registerErrors: [{code: string, description: string}]; - - constructor(private router: Router, private route: ActivatedRoute, private http: HttpClient) - { - if (this.route.snapshot.queryParams["ReturnUrl"]) - this.redirectURI = this.route.snapshot.queryParams["ReturnUrl"]; - if (this.route.snapshot.queryParams["otac"]) - this.useOTAC(this.route.snapshot.queryParams["otac"]); - } - - async login() - { - this.http.post("/api/account/login", this.loginInformation).pipe(catchError((error => - { - this.loginErrors = error.error; - return EMPTY; - }))).subscribe(() => - { - window.location.href = this.redirectURI; - }); - } - - useOTAC(otac: string) - { - this.http.post("/api/account/otac-login", {"otac": otac}).pipe(catchError((error => - { - this.registerErrors = error.error; - return EMPTY; - }))).subscribe(() => - { - window.location.href = this.redirectURI; - }); - } - - async register() - { - // @ts-ignore - this.http.post("/api/account/register", this.signinInformation, {responseType: "text"}).pipe(catchError((error => - { - this.registerErrors = JSON.parse(error.error); - return EMPTY; - }))).subscribe(otac => { this.useOTAC(otac); }); - } -} diff --git a/src/styles.scss b/src/styles.scss index 105625c2..326c9acc 100644 --- a/src/styles.scss +++ b/src/styles.scss @@ -33,7 +33,6 @@ h6 @import '~@angular/material/theming'; @include mat-core(); -// Define the default theme (same as the example above). $primary: (default: #0a1128); $accent: (default: #e23c00, lighter: #ff9149); $theme: mat-dark-theme($primary, $accent); diff --git a/static/iconfont/material-icons.css b/static/iconfont/material-icons.css index 2270c09d..e9ca4400 100644 --- a/static/iconfont/material-icons.css +++ b/static/iconfont/material-icons.css @@ -1,36 +1,36 @@ @font-face { - font-family: 'Material Icons'; - font-style: normal; - font-weight: 400; - src: url(MaterialIcons-Regular.eot); /* For IE6-8 */ - src: local('Material Icons'), - local('MaterialIcons-Regular'), - url(MaterialIcons-Regular.woff2) format('woff2'), - url(MaterialIcons-Regular.woff) format('woff'), - url(MaterialIcons-Regular.ttf) format('truetype'); + font-family: 'Material Icons'; + font-style: normal; + font-weight: 400; + src: url(/iconfont/MaterialIcons-Regular.eot); /* For IE6-8 */ + src: local('Material Icons'), + local('MaterialIcons-Regular'), + url(/iconfont/MaterialIcons-Regular.woff2) format('woff2'), + url(/iconfont/MaterialIcons-Regular.woff) format('woff'), + url(/iconfont/MaterialIcons-Regular.ttf) format('truetype'); } .material-icons { - font-family: 'Material Icons'; - font-weight: normal; - font-style: normal; - font-size: 24px; /* Preferred icon size */ - display: inline-block; - line-height: 1; - text-transform: none; - letter-spacing: normal; - word-wrap: normal; - white-space: nowrap; - direction: ltr; + font-family: 'Material Icons'; + font-weight: normal; + font-style: normal; + font-size: 24px; /* Preferred icon size */ + display: inline-block; + line-height: 1; + text-transform: none; + letter-spacing: normal; + word-wrap: normal; + white-space: nowrap; + direction: ltr; - /* Support for all WebKit browsers. */ - -webkit-font-smoothing: antialiased; - /* Support for Safari and Chrome. */ - text-rendering: optimizeLegibility; + /* Support for all WebKit browsers. */ + -webkit-font-smoothing: antialiased; + /* Support for Safari and Chrome. */ + text-rendering: optimizeLegibility; - /* Support for Firefox. */ - -moz-osx-font-smoothing: grayscale; + /* Support for Firefox. */ + -moz-osx-font-smoothing: grayscale; - /* Support for IE. */ - font-feature-settings: 'liga'; + /* Support for IE. */ + font-feature-settings: 'liga'; }