Skip to content

Commit

Permalink
MOSIP:32449 - android logout issue. (#730)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sudeep7353 authored Apr 16, 2024
1 parent 2789ee3 commit 31d75ab
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 19 deletions.
23 changes: 23 additions & 0 deletions src/app/app.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { Directory, Filesystem } from '@capacitor/filesystem';
import { Toast } from '@capacitor/toast';
import { sha256 } from 'js-sha256';
import { MatTableDataSource } from '@angular/material/table';
import { App } from '@capacitor/app';
import { environment } from 'src/environments/environment';
export default class Utils {
static getCurrentDate() {
let now = new Date();
Expand Down Expand Up @@ -1038,4 +1040,25 @@ export default class Utils {
dataSource.paginator.firstPage();
}
}

static androidAppExit(resourceBundleJson: any, dialog: MatDialog) {
const isAndroidAppMode = environment.isAndroidAppMode == 'yes' ? true : false;
if (isAndroidAppMode) {
let resourceBundle = resourceBundleJson.dialogMessages;
let successMsg = 'success';
let logoutMsg = 'logoutMessage';
const dialogRef = Utils.showSuccessMessage(
resourceBundle,
successMsg,
logoutMsg,
dialog
);
dialogRef.afterClosed().subscribe((res) => {
App.exitApp().catch((error) => {
console.log(error);
});
});
}
}

}
5 changes: 3 additions & 2 deletions src/app/core/components/dialog/dialog.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -493,9 +493,10 @@ export class DialogComponent implements OnInit {
}

// Close the dialog when the user clicks on the "OK" button, and initiate the logout process.
onOkClick(): void {
async onOkClick() {
this.dialogRef.close();
this.logoutservice.logout();
await this.logoutservice.logout();
Utils.androidAppExit(this.resourceBundleJson, this.dialog);
}

setConsent() {
Expand Down
18 changes: 1 addition & 17 deletions src/app/core/components/header/header.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,7 @@ export class HeaderComponent implements OnInit {
}
async onItem() {
await this.logoutService.logout();
const isAndroidAppMode = environment.isAndroidAppMode == 'yes' ? true : false;
if (isAndroidAppMode) {
let resourceBundle = this.resourceBundleJson.dialogMessages;
let successMsg = 'success';
let logoutMsg = 'logoutMessage';
const dialogRef = Utils.showSuccessMessage(
resourceBundle,
successMsg,
logoutMsg,
this.dialog
);
dialogRef.afterClosed().subscribe((res) => {
App.exitApp().catch((error) => {
console.log(error);
});
});
}
Utils.androidAppExit(this.resourceBundleJson, this.dialog);
}
async ngOnInit() {
this.translate.use(this.userProfileService.getUserPreferredLanguage());
Expand Down

0 comments on commit 31d75ab

Please sign in to comment.