login api integration

integrating login API with aConnect backend
mazdak/UX-1381
Mazdak Gibran 8 hours ago
parent f93372a5ca
commit 77282eeca7

@ -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'));
}
}
}

@ -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
}

@ -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'));

@ -8,6 +8,7 @@
"forgotPassword":"هل نسيت كلمة السر؟",
"login":"تسجيل الدخول",
"dashboardTitle":"لوحة القيادة",
"passwordChangeRequired": "تغيير كلمة المرور مطلوب",
"monthlyReqTitle":"الطلبات الشهرية",
"monthlySmsTitle":"الرسائل القصيرة الشهرية",
"Dashboard":"لوحة القيادة",

@ -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",

@ -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"]
])
};

@ -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"]
])
};

Loading…
Cancel
Save