fix issues

This commit is contained in:
Peter Maquiran
2024-12-05 19:14:11 +01:00
parent dad392335e
commit 5a1bbe6103
46 changed files with 378 additions and 1748 deletions
+59 -59
View File
@@ -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);
// })
// );
// }
}