diff --git a/src/app/authenticate/login/login.component.ts b/src/app/authenticate/login/login.component.ts index af3ca94..1703c88 100644 --- a/src/app/authenticate/login/login.component.ts +++ b/src/app/authenticate/login/login.component.ts @@ -105,8 +105,8 @@ export class LoginComponent { this.miscService.handleSuccess(this.translateService.instant('loginSuccess')); } else { - this.router.navigate(['home/changepassword']); - this.miscService.handleSuccess(this.translateService.instant('changePassword')); + this.router.navigate(['/changepassword']); + this.miscService.handleSuccess(this.translateService.instant('passwordChangeRequired')); } } } diff --git a/src/app/services/auth.service.ts b/src/app/services/auth.service.ts index 8041f66..dd9e64f 100644 --- a/src/app/services/auth.service.ts +++ b/src/app/services/auth.service.ts @@ -22,23 +22,25 @@ export class AuthService { let login = false; let userId = User_Data.Username; let password = User_Data.Password; - let data = { "userId": User_Data.Username, "userPassword": btoa(User_Data.Password) }; + let data = { "userId": userId, "password": password}; - let url = '/loginUser'; + let url = '/authentication/login'; let response: any = await this.httpService.postRequest(url, data)!.toPromise(); if (!(response instanceof HttpErrorResponse)) { if ((await response["errorMessage"] == undefined)) { if (response) { login = true; - localStorage.setItem('USERKEY', userId); + localStorage.setItem('userId', userId); let res = JSON.parse(JSON.stringify(response)); - let permission = JSON.parse(res['userPermission']); - localStorage.setItem('SIDENAV', res['userPermission']); - this.firstLogin = res['firstLogin']; - localStorage.setItem('USERNAME', res['userName']); - localStorage.setItem('token', res['token']) + // let permission = JSON.parse(res['userPermission']); + // localStorage.setItem('SIDENAV', res['userPermission']); + localStorage.setItem('userFullname', res.user.userFullname); + localStorage.setItem('userId', res.user.userId); + localStorage.setItem('token', res.token); + this.firstLogin = response.requiresPasswordChange; return res; + } } let res = response; @@ -48,7 +50,7 @@ export class AuthService { } IsLoggedIn() { - if (this.storageService.getItem('USERKEY') !== null) + if (this.storageService.getItem('userId') !== null) return true; else return false; @@ -74,7 +76,7 @@ export class AuthService { let uCreds = { token: this.getToken() }; let porOrgacode = CONSTANTS.POR_ORGACODE; let refreshTokenData: any = { - cmpUserId: localStorage.getItem('USERKEY'), + cmpUserId: localStorage.getItem('userId'), token: uCreds.token, porOrgacode: porOrgacode } diff --git a/src/app/shared/services/http.service.ts b/src/app/shared/services/http.service.ts index 99f0ee7..75f6b18 100644 --- a/src/app/shared/services/http.service.ts +++ b/src/app/shared/services/http.service.ts @@ -19,7 +19,7 @@ export class HttpService { getRequest(url: string, queryParams?: HttpParams, pathParams?: any, showLoader = true, options?: any) { - const custId: any = localStorage.getItem("USERKEY"); + const custId: any = localStorage.getItem("userId"); let headers = new HttpHeaders().set("Content-Type", "application/json"); const authorization = "Bearer " + localStorage.getItem('token'); @@ -50,7 +50,7 @@ export class HttpService { } postRequest(url: string, data?: any, pathParams?: any, isMultipart = false, showLoader = true) { - const custId = localStorage.getItem("USERKEY"); + const custId = localStorage.getItem("userId"); let headers = new HttpHeaders().set("Content-Type", "application/json"); let apiUrl = this.API_PATH + url; this.miscService.showLoader(); @@ -86,7 +86,7 @@ export class HttpService { } putRequest(url: string, data: any, pathParams?: any, isMultipart = false, showLoader = true) { - const custId: any = localStorage.getItem("USERKEY"); + const custId: any = localStorage.getItem("userId"); let headers = new HttpHeaders().set("Content-Type", "application/json"); headers = headers.set("cmpUserId", custId); headers = headers.set("Authorization", "Bearer " + localStorage.getItem('token')); @@ -122,7 +122,7 @@ export class HttpService { deleteRequest(url: any, data: any, pathParams?: any, isMultipart = false, showLoader = true) { - const custId: any = localStorage.getItem("USERKEY"); + const custId: any = localStorage.getItem("userId"); let apiUrl = this.API_PATH + url; let headers = new HttpHeaders().set("Content-Type", "application/json"); headers = headers.set("Authorization", "Bearer " + localStorage.getItem('token')); diff --git a/src/assets/i18n/Arabic.json b/src/assets/i18n/Arabic.json index 24865ce..62bcfcf 100644 --- a/src/assets/i18n/Arabic.json +++ b/src/assets/i18n/Arabic.json @@ -8,6 +8,7 @@ "forgotPassword":"هل نسيت كلمة السر؟", "login":"تسجيل الدخول", "dashboardTitle":"لوحة القيادة", + "passwordChangeRequired": "تغيير كلمة المرور مطلوب", "monthlyReqTitle":"الطلبات الشهرية", "monthlySmsTitle":"الرسائل القصيرة الشهرية", "Dashboard":"لوحة القيادة", diff --git a/src/assets/i18n/English.json b/src/assets/i18n/English.json index 318aaf3..23d2076 100644 --- a/src/assets/i18n/English.json +++ b/src/assets/i18n/English.json @@ -152,6 +152,7 @@ "senderNamePlaceHolder":"Enter Sender Name", "enterIdentityValue":"Enter Identity Value", "senderName":"Sender Name", + "passwordChangeRequired": "Password Change Required", "Next": "Next", "ERR_APP_B_0001":"Internal Server Error", "ERR_APP_B_0002":"Possible connection error with {{value1}} module", diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index d0bcf0e..ff7051f 100644 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -4,6 +4,6 @@ export const environment = { buildNumber: '1.0', buildDate: '27-11-2025', apiPath: new Map([ - ["API_PATH", "http://localhost:8090/MCONNECT"] + ["API_PATH", "http://localhost:8080/aconnect"] ]) }; diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 8cee1d8..18dfbfe 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -4,6 +4,6 @@ export const environment = { buildNumber: '1.0', buildDate: '27-11-2025', apiPath: new Map([ - ["API_PATH", "http://localhost:8090/MCONNECT"] + ["API_PATH", "http://localhost:8080/aconnect"] ]) };