implemented hacky interceptor

implemented a hacky solution wich allows unauthorized user password updates to be processed correctly
pull/8/head
FlayInAHook 4 years ago
parent dc8d60748d
commit 7fb79a0a45

@ -47,7 +47,6 @@ import { MenuListItemComponent } from './components/menu-list-item/menu-list-ite
import { SidenavProfileComponent } from './components/sidenav-profile/sidenav-profile.component';
import { NavService } from './components/menu-list-item/nav.service';
import { TokenInterceptor } from './helper/token.interceptor';
import { HttpErrorInterceptor } from './helper/http-error.interceptor';
import { BikeComponent } from './pages/dataPages/bike/bike.component';
import {
TableComponent,

@ -27,14 +27,18 @@ export class TokenInterceptor implements HttpInterceptor {
} else {
//server error;
if (error.status === 401) {
return this.handle401Error(request, next);
var urlSplit : string[] = error.url.split("/");
if (urlSplit[3] === "users" && urlSplit[5] === "update"){
errorMessage = "Das aktuelle Passwort ist inkorrekt.";
} else {
return this.handle401Error(request, next);
}
} else {
errorMessage = `Error Code: ${error.status}\nMessage: ${error.message}`;
errorMessage = `Error Code: ${error.status}\nMessage: ${error.message}.`;
}
}
this.snackBar.openSnackBar(errorMessage, "Ok", true);
//return throwError(errorMessage);
return throwError(errorMessage);
}));
}

@ -67,12 +67,6 @@ export class ProfileComponent implements OnInit {
data => {
this.snackBar.openSnackBar("Das Passwort wurde erfolgreich aktualisiert", "Ok");
console.log(JSON.stringify(data));
},
(error) => {
this.errorOccurred = true;
this.errorMessage =
error.error.message ||
'Ein Fehler ist aufgetreten. Bitte melden sie dies ihrem Administrator.';
}
)
.add(() => {

Loading…
Cancel
Save