diff --git a/src/app/core/authentication/authentication.service.ts b/src/app/core/authentication/authentication.service.ts index bb6385608..b33f2ae5f 100644 --- a/src/app/core/authentication/authentication.service.ts +++ b/src/app/core/authentication/authentication.service.ts @@ -39,6 +39,7 @@ export class AuthenticationService { /** User credentials. */ private credentials: Credentials; + private dialogShown = false; /** Key to store credentials in storage. */ private credentialsStorageKey = 'mifosXCredentials'; /** Key to store oauth token details in storage. */ @@ -202,6 +203,7 @@ export class AuthenticationService { } this.authenticationInterceptor.removeAuthorization(); this.setCredentials(); + this.resetDialog(); return of(true); } @@ -266,6 +268,18 @@ export class AuthenticationService { return this.http.get('/twofactor'); } + showDialog() { + this.dialogShown = true; + } + + resetDialog() { + this.dialogShown = false; + } + + hasDialogBeenShown() { + return this.dialogShown; + } + /** * Requests OTP to be sent via the given delivery method. * @param {any} deliveryMethod Delivery method for the OTP. diff --git a/src/app/home/home.component.ts b/src/app/home/home.component.ts index 56c347446..2e005efbe 100644 --- a/src/app/home/home.component.ts +++ b/src/app/home/home.component.ts @@ -10,6 +10,7 @@ import { startWith, map } from 'rxjs/operators'; /** Custom Imports. */ import { activities } from './activities'; +import { WarningDialogComponent } from './warning-dialog/warning-dialog.component'; /** Custom Services */ import { AuthenticationService } from '../core/authentication/authentication.service'; @@ -62,7 +63,7 @@ export class HomeComponent implements OnInit, AfterViewInit { private router: Router, private dialog: MatDialog, private configurationWizardService: ConfigurationWizardService, - private popoverService: PopoverService) { } + private popoverService: PopoverService,) { } /** * Sets the username of the authenticated user. @@ -72,6 +73,10 @@ export class HomeComponent implements OnInit, AfterViewInit { const credentials = this.authenticationService.getCredentials(); this.username = credentials.username; this.setFilteredActivities(); + if (!this.authenticationService.hasDialogBeenShown()) { + this.dialog.open(WarningDialogComponent); + this.authenticationService.showDialog(); + } } /** diff --git a/src/app/home/home.module.ts b/src/app/home/home.module.ts index 2d131b3c2..fc565db21 100644 --- a/src/app/home/home.module.ts +++ b/src/app/home/home.module.ts @@ -1,5 +1,6 @@ /** Angular Imports */ import { NgModule } from '@angular/core'; +import { MatDialogModule } from '@angular/material/dialog'; /** Custom Modules */ import { SharedModule } from '../shared/shared.module'; @@ -13,6 +14,7 @@ import { AmountCollectedPieComponent } from './dashboard/amount-collected-pie/am import { AmountDisbursedPieComponent } from './dashboard/amount-disbursed-pie/amount-disbursed-pie.component'; import { ClientTrendsBarComponent } from './dashboard/client-trends-bar/client-trends-bar.component'; import { TranslateModule } from '@ngx-translate/core'; +import { WarningDialogComponent } from './warning-dialog/warning-dialog.component' /** * Home Component @@ -21,6 +23,7 @@ import { TranslateModule } from '@ngx-translate/core'; */ @NgModule({ imports: [ + MatDialogModule, SharedModule, PipesModule, HomeRoutingModule, @@ -31,7 +34,8 @@ import { TranslateModule } from '@ngx-translate/core'; DashboardComponent, AmountCollectedPieComponent, AmountDisbursedPieComponent, - ClientTrendsBarComponent + ClientTrendsBarComponent, + WarningDialogComponent ], providers: [ ] }) diff --git a/src/app/home/warning-dialog/warning-dialog.component.html b/src/app/home/warning-dialog/warning-dialog.component.html new file mode 100644 index 000000000..cc00ee30c --- /dev/null +++ b/src/app/home/warning-dialog/warning-dialog.component.html @@ -0,0 +1,5 @@ +