mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-09 03:04:20 -04:00
Reworking the auto login
This commit is contained in:
parent
73c9b4261f
commit
042acce92c
6
package-lock.json
generated
6
package-lock.json
generated
@ -2333,9 +2333,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"angular-auth-oidc-client": {
|
||||
"version": "10.0.15",
|
||||
"resolved": "https://registry.npmjs.org/angular-auth-oidc-client/-/angular-auth-oidc-client-10.0.15.tgz",
|
||||
"integrity": "sha512-DrYlR4TrnZX+Xr+Vnh1GlkiTmi7LDBnijEkW2NNgLfPp0D6T9ETtl4b2LgcGywLnpNRDBtaX7nOPY1GYL82bZw==",
|
||||
"version": "10.0.14",
|
||||
"resolved": "https://registry.npmjs.org/angular-auth-oidc-client/-/angular-auth-oidc-client-10.0.14.tgz",
|
||||
"integrity": "sha512-+cHlEC3vleBpudNyJkjTV9CLc8+Mt7/MlGiTuE9Fn9gKkxOIQ0kcwyLfbnfCnbb9oGwcPvKhzNbqr4VyUYJMXQ==",
|
||||
"requires": {
|
||||
"common-tags": "1.8.0",
|
||||
"jsrsasign-reduced": "8.0.12",
|
||||
|
@ -19,7 +19,7 @@
|
||||
"@angular/platform-browser": "^9.1.0",
|
||||
"@angular/platform-browser-dynamic": "^9.1.0",
|
||||
"@angular/router": "^9.1.0",
|
||||
"angular-auth-oidc-client": "^10.0.15",
|
||||
"angular-auth-oidc-client": "10.0.14",
|
||||
"bootstrap": "^4.4.1",
|
||||
"detect-browser": "^5.0.0",
|
||||
"hammerjs": "^2.0.8",
|
||||
|
@ -8,7 +8,7 @@
|
||||
<br/>
|
||||
<mat-form-field class="w-75">
|
||||
<mat-label>Username</mat-label>
|
||||
<input matInput name="accountUsername" [(ngModel)]="account.username">
|
||||
<input matInput name="accountUsername" [(ngModel)]="account.username" required>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
|
@ -2,11 +2,9 @@ import {NgModule} from '@angular/core';
|
||||
import {RouterModule, Routes} from "@angular/router";
|
||||
import {UnauthorizedComponent} from "./unauthorized/unauthorized.component";
|
||||
import {LogoutComponent} from "./logout/logout.component";
|
||||
import {AutologinComponent} from "./autologin/autologin.component";
|
||||
|
||||
const routes: Routes = [
|
||||
{path: "logout", component: LogoutComponent},
|
||||
{path: "autologin", component: AutologinComponent},
|
||||
{path: "unauthorized", component: UnauthorizedComponent},
|
||||
];
|
||||
|
||||
|
@ -2,11 +2,10 @@ import {APP_INITIALIZER, NgModule} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {AccountComponent} from "./account/account.component";
|
||||
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 {ConfigResult, OidcConfigService, OidcSecurityService, OpenIdConfiguration, AuthModule as OidcModule} from "angular-auth-oidc-client";
|
||||
import {HTTP_INTERCEPTORS, HttpClient, HttpClientModule} from "@angular/common/http";
|
||||
import {HTTP_INTERCEPTORS, HttpClient} from "@angular/common/http";
|
||||
import {AuthGuard} from "./misc/authenticated-guard.service";
|
||||
import {AuthorizerInterceptor} from "./misc/authorizer-interceptor.service";
|
||||
import {MatFormFieldModule} from "@angular/material/form-field";
|
||||
@ -20,7 +19,7 @@ import {MatSliderModule} from "@angular/material/slider";
|
||||
import {MatTooltipModule} from "@angular/material/tooltip";
|
||||
import {MatRippleModule} from "@angular/material/core";
|
||||
import {MatCardModule} from "@angular/material/card";
|
||||
import {FormsModule, ReactiveFormsModule} from "@angular/forms";
|
||||
import {FormsModule} from "@angular/forms";
|
||||
import {MatTabsModule} from "@angular/material/tabs";
|
||||
import {MatCheckboxModule} from "@angular/material/checkbox";
|
||||
|
||||
@ -31,7 +30,6 @@ export function loadConfig(oidcConfigService: OidcConfigService)
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
AutologinComponent,
|
||||
AuthPipe,
|
||||
AccountComponent,
|
||||
UnauthorizedComponent,
|
||||
@ -86,17 +84,17 @@ export class AuthModule
|
||||
post_logout_redirect_uri: "/logout",
|
||||
client_id: 'kyoo.webapp',
|
||||
response_type: "code",
|
||||
trigger_authorization_result_event: true,
|
||||
trigger_authorization_result_event: false,
|
||||
scope: "openid profile",
|
||||
silent_renew: true,
|
||||
silent_renew_url: "/silent",
|
||||
silent_renew_url: "/silent.html",
|
||||
use_refresh_token: false,
|
||||
start_checksession: true,
|
||||
|
||||
forbidden_route: '/Forbidden',
|
||||
unauthorized_route: '/Unauthorized',
|
||||
log_console_warning_active: true,
|
||||
log_console_debug_active: false
|
||||
log_console_debug_active: true
|
||||
};
|
||||
|
||||
this.oidcSecurityService.setupModule(config, configResult.authWellknownEndpoints);
|
||||
|
@ -62,13 +62,6 @@ export class AuthService
|
||||
this.oidcSecurityService.getIsAuthorized().subscribe((authorized: boolean) =>
|
||||
{
|
||||
this.isAuthenticated = authorized;
|
||||
if (!authorized)
|
||||
{
|
||||
if (document.cookie.indexOf("Authenticated=true") != -1)
|
||||
this.router.navigate(['/autologin']);
|
||||
}
|
||||
else
|
||||
document.cookie = "Authenticated=true; expires=" + new Date(2147483647 * 1000).toUTCString();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1 +0,0 @@
|
||||
<p>autologin works!</p>
|
@ -1,25 +0,0 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {AuthService} from "../auth.service";
|
||||
|
||||
@Component({
|
||||
selector: 'app-autologin',
|
||||
templateUrl: './autologin.component.html',
|
||||
styleUrls: ['./autologin.component.scss']
|
||||
})
|
||||
export class AutologinComponent implements OnInit
|
||||
{
|
||||
constructor(private authManager: AuthService)
|
||||
{
|
||||
this.authManager.oidcSecurityService.onModuleSetup.subscribe(() =>
|
||||
{
|
||||
this.authManager.login();
|
||||
})
|
||||
}
|
||||
|
||||
ngOnInit(): void
|
||||
{
|
||||
if (this.authManager.oidcSecurityService.moduleSetup) {
|
||||
this.authManager.login();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user