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 { SidenavProfileComponent } from './components/sidenav-profile/sidenav-profile.component';
import { NavService } from './components/menu-list-item/nav.service'; import { NavService } from './components/menu-list-item/nav.service';
import { TokenInterceptor } from './helper/token.interceptor'; import { TokenInterceptor } from './helper/token.interceptor';
import { HttpErrorInterceptor } from './helper/http-error.interceptor';
import { BikeComponent } from './pages/dataPages/bike/bike.component'; import { BikeComponent } from './pages/dataPages/bike/bike.component';
import { import {
TableComponent, TableComponent,

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

@ -67,12 +67,6 @@ export class ProfileComponent implements OnInit {
data => { data => {
this.snackBar.openSnackBar("Das Passwort wurde erfolgreich aktualisiert", "Ok"); this.snackBar.openSnackBar("Das Passwort wurde erfolgreich aktualisiert", "Ok");
console.log(JSON.stringify(data)); 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(() => { .add(() => {

Loading…
Cancel
Save