mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-21 13:55:51 +00:00
fix issues
This commit is contained in:
@@ -91,34 +91,34 @@ export class AuthService {
|
||||
|
||||
}
|
||||
|
||||
async loginContenteProduction(user: UserForm, { saveSession = true }): Promise<UserSession> {
|
||||
user.BasicAuthKey = 'Basic ' + btoa(user.username + ':' + this.aesencrypt.encrypt(user.password, user.username));
|
||||
// async loginContenteProduction(user: UserForm, { saveSession = true }): Promise<UserSession> {
|
||||
// user.BasicAuthKey = 'Basic ' + btoa(user.username + ':' + this.aesencrypt.encrypt(user.password, user.username));
|
||||
|
||||
this.headers = this.headers.set('Authorization', user.BasicAuthKey);
|
||||
this.opts = {
|
||||
headers: this.headers,
|
||||
}
|
||||
// this.headers = this.headers.set('Authorization', user.BasicAuthKey);
|
||||
// this.opts = {
|
||||
// headers: this.headers,
|
||||
// }
|
||||
|
||||
let response: any;
|
||||
// let response: any;
|
||||
|
||||
try {
|
||||
response = await this.http.post<UserSession>(environment.apiURL + "UserAuthentication/Login", '', this.opts).toPromise();
|
||||
console.log('JWT', response)
|
||||
// try {
|
||||
// response = await this.http.post<UserSession>(environment.apiURL + "UserAuthentication/Login", '', this.opts).toPromise();
|
||||
// console.log('JWT', response)
|
||||
|
||||
if (saveSession) {
|
||||
/* this.SetSession(response, user) */
|
||||
console.log('teste', response);
|
||||
// if (saveSession) {
|
||||
// /* this.SetSession(response, user) */
|
||||
// console.log('teste', response);
|
||||
|
||||
return response
|
||||
// return response
|
||||
|
||||
}
|
||||
} catch (error) {
|
||||
this.httpErroHandle.httpStatusHandle(error)
|
||||
} finally {
|
||||
return response
|
||||
}
|
||||
// }
|
||||
// } catch (error) {
|
||||
// this.httpErroHandle.httpStatusHandle(error)
|
||||
// } finally {
|
||||
// return response
|
||||
// }
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
// async UpdateLogin() {}
|
||||
|
||||
@@ -152,50 +152,50 @@ export class AuthService {
|
||||
await alert.present();
|
||||
}
|
||||
|
||||
async logoutUser() {
|
||||
// async logoutUser() {
|
||||
|
||||
this.headers = this.headers.set('Authorization', 'Bearer ' + SessionStore.user.Authorization);
|
||||
// this.headers = this.headers.set('Authorization', 'Bearer ' + SessionStore.user.Authorization);
|
||||
|
||||
this.opts = {
|
||||
headers: this.headers,
|
||||
}
|
||||
// this.opts = {
|
||||
// headers: this.headers,
|
||||
// }
|
||||
|
||||
let response: any;
|
||||
try {
|
||||
response = await this.http.delete<UserSession>(environment.apiURL + "userauthentication/Logout", this.opts).toPromise();
|
||||
SessionStore.user.Authorization = "";
|
||||
SessionStore.user.RefreshToken = "";
|
||||
} catch (error) {
|
||||
this.errorHandler.handleError(error);
|
||||
this.httpErroHandle.loginHttpStatusHandle(error)
|
||||
captureException(error);
|
||||
// let response: any;
|
||||
// try {
|
||||
// response = await this.http.delete<UserSession>(environment.apiURL + "userauthentication/Logout", this.opts).toPromise();
|
||||
// SessionStore.user.Authorization = "";
|
||||
// SessionStore.user.RefreshToken = "";
|
||||
// } catch (error) {
|
||||
// this.errorHandler.handleError(error);
|
||||
// this.httpErroHandle.loginHttpStatusHandle(error)
|
||||
// captureException(error);
|
||||
|
||||
if(error?.status == 403) {
|
||||
console.log('error?.status == 403')
|
||||
}
|
||||
// if(error?.status == 403) {
|
||||
// console.log('error?.status == 403')
|
||||
// }
|
||||
|
||||
} finally {
|
||||
return response
|
||||
}
|
||||
}
|
||||
// } finally {
|
||||
// return response
|
||||
// }
|
||||
// }
|
||||
|
||||
refreshToken() {
|
||||
// refreshToken() {
|
||||
|
||||
return this.http
|
||||
.put<any>(environment.apiURL + "UserAuthentication/RefreshToken", {
|
||||
refreshToken: SessionStore.user.RefreshToken,
|
||||
},)
|
||||
.pipe(
|
||||
tap((tokens) => {
|
||||
console.log(tokens)
|
||||
SessionStore.user.Authorization = tokens.Authorization;
|
||||
SessionStore.user.RefreshToken = tokens.refreshToken;
|
||||
// return this.http
|
||||
// .put<any>(environment.apiURL + "UserAuthentication/RefreshToken", {
|
||||
// refreshToken: SessionStore.user.RefreshToken,
|
||||
// },)
|
||||
// .pipe(
|
||||
// tap((tokens) => {
|
||||
// console.log(tokens)
|
||||
// SessionStore.user.Authorization = tokens.Authorization;
|
||||
// SessionStore.user.RefreshToken = tokens.refreshToken;
|
||||
|
||||
}),
|
||||
catchError((error) => {
|
||||
this.logoutUser();
|
||||
return of(false);
|
||||
})
|
||||
);
|
||||
}
|
||||
// }),
|
||||
// catchError((error) => {
|
||||
// this.logoutUser();
|
||||
// return of(false);
|
||||
// })
|
||||
// );
|
||||
// }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user