feat: integrate Google OAuth for user authentication and update login UI
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { RouterOutlet } from '@angular/router';
|
import { Router, RouterOutlet } from '@angular/router';
|
||||||
import { OAuthService } from 'angular-oauth2-oidc';
|
import { OAuthService } from 'angular-oauth2-oidc';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -12,4 +12,16 @@ import { OAuthService } from 'angular-oauth2-oidc';
|
|||||||
})
|
})
|
||||||
export class AppComponent {
|
export class AppComponent {
|
||||||
title = 'Digitálny asistent PAS';
|
title = 'Digitálny asistent PAS';
|
||||||
|
constructor(private readonly as: OAuthService, private readonly router: Router) {
|
||||||
|
this.as.configure({
|
||||||
|
issuer: 'https://accounts.google.com',
|
||||||
|
redirectUri: window.location.origin + '/login',
|
||||||
|
clientId: '1000025801082-09ikmt61a9c9vbdjhpdab9b0ui3vdnij.apps.googleusercontent.com',
|
||||||
|
dummyClientSecret: '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',
|
||||||
|
scope: 'openid profile email',
|
||||||
|
responseType: 'code',
|
||||||
|
strictDiscoveryDocumentValidation: false,
|
||||||
|
timeoutFactor: 0.01,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ import { adapterFactory } from 'angular-calendar/date-adapters/date-fns';
|
|||||||
// code view
|
// code view
|
||||||
import { provideHighlightOptions } from 'ngx-highlightjs';
|
import { provideHighlightOptions } from 'ngx-highlightjs';
|
||||||
import 'highlight.js/styles/atom-one-dark.min.css';
|
import 'highlight.js/styles/atom-one-dark.min.css';
|
||||||
|
import { OAuthModule, provideOAuthClient } from 'angular-oauth2-oidc';
|
||||||
|
|
||||||
export function HttpLoaderFactory(http: HttpClient): any {
|
export function HttpLoaderFactory(http: HttpClient): any {
|
||||||
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
|
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
|
||||||
@@ -66,6 +67,13 @@ export const appConfig: ApplicationConfig = {
|
|||||||
withComponentInputBinding()
|
withComponentInputBinding()
|
||||||
),
|
),
|
||||||
provideHttpClient(withInterceptorsFromDi()),
|
provideHttpClient(withInterceptorsFromDi()),
|
||||||
|
provideOAuthClient({
|
||||||
|
resourceServer: {
|
||||||
|
allowedUrls: ['http://localhost:5000', 'https://localhost:4200', 'https://centrum.lesko.me', 'https://beta.e-dias.sk/'],
|
||||||
|
sendAccessToken: true,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
|
||||||
provideClientHydration(),
|
provideClientHydration(),
|
||||||
provideAnimationsAsync(),
|
provideAnimationsAsync(),
|
||||||
importProvidersFrom(
|
importProvidersFrom(
|
||||||
|
|||||||
@@ -17,12 +17,12 @@
|
|||||||
<span class="f-s-14 d-block f-s-14 m-t-8">Váš uživateľský prístup</span>
|
<span class="f-s-14 d-block f-s-14 m-t-8">Váš uživateľský prístup</span>
|
||||||
|
|
||||||
<div class="row m-t-24 align-items-center">
|
<div class="row m-t-24 align-items-center">
|
||||||
<button mat-stroked-button class="w-100">
|
<a mat-stroked-button class="w-100" (click)="googleLogin()">
|
||||||
<div class="d-flex align-items-center">
|
<div class="d-flex align-items-center">
|
||||||
<img src="/assets/images/svgs/google-icon.svg" alt="google" width="16" class="m-r-8" />
|
<img src="/assets/images/svgs/google-icon.svg" alt="google" width="16" class="m-r-8" />
|
||||||
Prihlásiť sa pomocou Google
|
Prihlásiť sa pomocou Google
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</a>
|
||||||
<!-- <div class="col-12 col-sm-6">
|
<!-- <div class="col-12 col-sm-6">
|
||||||
<button mat-stroked-button class="w-100 d-flex align-items-center">
|
<button mat-stroked-button class="w-100 d-flex align-items-center">
|
||||||
<div class="d-flex align-items-center">
|
<div class="d-flex align-items-center">
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { FormGroup, FormControl, Validators, FormsModule, ReactiveFormsModule }
|
|||||||
import { Router, RouterModule } from '@angular/router';
|
import { Router, RouterModule } from '@angular/router';
|
||||||
import { MaterialModule } from '../../../material.module';
|
import { MaterialModule } from '../../../material.module';
|
||||||
import { BrandingComponent } from '../../../layouts/full/vertical/sidebar/branding.component';
|
import { BrandingComponent } from '../../../layouts/full/vertical/sidebar/branding.component';
|
||||||
|
import { OAuthService } from 'angular-oauth2-oidc';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-side-login',
|
selector: 'app-side-login',
|
||||||
@@ -13,7 +14,7 @@ import { BrandingComponent } from '../../../layouts/full/vertical/sidebar/brandi
|
|||||||
export class AppSideLoginComponent {
|
export class AppSideLoginComponent {
|
||||||
options: any;
|
options: any;
|
||||||
|
|
||||||
constructor(private settings: CoreService, private router: Router) {
|
constructor(private settings: CoreService, private router: Router, private readonly as: OAuthService) {
|
||||||
this.options = this.settings.getOptions();
|
this.options = this.settings.getOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,6 +27,15 @@ export class AppSideLoginComponent {
|
|||||||
return this.form.controls;
|
return this.form.controls;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
googleLogin() {
|
||||||
|
console.warn('Google login initiated');
|
||||||
|
this.as.loadDiscoveryDocumentAndLogin()
|
||||||
|
.then(_ =>{}
|
||||||
|
// this.as.initLoginFlowInPopup()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
submit() {
|
submit() {
|
||||||
// console.log(this.form.value);
|
// console.log(this.form.value);
|
||||||
this.router.navigate(['/dashboards/dashboard1']);
|
this.router.navigate(['/dashboards/dashboard1']);
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import {
|
|||||||
} from '../front-pagesData';
|
} from '../front-pagesData';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { MediaMatcher } from '@angular/cdk/layout';
|
import { MediaMatcher } from '@angular/cdk/layout';
|
||||||
import { ImageSliderComponent } from '../image-slider/image-slider.component';
|
|
||||||
import { FooterComponent } from '../footer/footer.component';
|
import { FooterComponent } from '../footer/footer.component';
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
import { TemplateVideoComponent } from '../template-video/template-video.component';
|
import { TemplateVideoComponent } from '../template-video/template-video.component';
|
||||||
@@ -26,7 +25,6 @@ import { Router, RouterModule } from '@angular/router';
|
|||||||
MaterialModule,
|
MaterialModule,
|
||||||
IconModule,
|
IconModule,
|
||||||
CommonModule,
|
CommonModule,
|
||||||
ImageSliderComponent,
|
|
||||||
FooterComponent,
|
FooterComponent,
|
||||||
RouterModule
|
RouterModule
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
|
<title>Digitálny asistent PAS</title>
|
||||||
<base href="/">
|
<base href="/">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
||||||
|
|||||||
Reference in New Issue
Block a user