diff --git a/hv2-ui/src/app/error-handler.interceptor.ts b/hv2-ui/src/app/error-handler.interceptor.ts index e09b662..3e3f925 100644 --- a/hv2-ui/src/app/error-handler.interceptor.ts +++ b/hv2-ui/src/app/error-handler.interceptor.ts @@ -19,7 +19,7 @@ export class ErrorHandlerInterceptor implements HttpInterceptor { intercept(request: HttpRequest, next: HttpHandler): Observable> { return next.handle(request).pipe( catchError((errorResponse: HttpErrorResponse) => { - this.messageService.add(`Intercepted http error: ${errorResponse}`) + this.messageService.add(`Intercepted http error: ${JSON.stringify(errorResponse, undefined, 4)}`) if (errorResponse.status === 401) { this.router.navigateByUrl('/login') } diff --git a/hv2-ui/src/app/login/login.component.css b/hv2-ui/src/app/login/login.component.css index e69de29..8397513 100644 --- a/hv2-ui/src/app/login/login.component.css +++ b/hv2-ui/src/app/login/login.component.css @@ -0,0 +1,9 @@ +mat-card { + max-width: 400px; + margin: 2em auto; + text-align: center; + } + + mat-form-field { + display: block; + } \ No newline at end of file diff --git a/hv2-ui/src/app/login/login.component.ts b/hv2-ui/src/app/login/login.component.ts index c15ddf5..4164e0b 100644 --- a/hv2-ui/src/app/login/login.component.ts +++ b/hv2-ui/src/app/login/login.component.ts @@ -41,6 +41,7 @@ export class LoginComponent implements OnInit { const password = this.form.get('password')?.value; await this.tokenService.login(username, password); } catch (err) { + this.messageService.add(`Login err: ${err.message}`) this.loginInvalid = true; } } else { diff --git a/hv2-ui/src/app/token.service.ts b/hv2-ui/src/app/token.service.ts index 5e3ce7d..c7661a0 100644 --- a/hv2-ui/src/app/token.service.ts +++ b/hv2-ui/src/app/token.service.ts @@ -2,6 +2,7 @@ import { Injectable } from '@angular/core'; import { MessageService } from './message.service'; import { HttpClient, HttpHeaders } from '@angular/common/http'; import { UserCreds } from './userCreds' +import { ThrowStmt } from '@angular/compiler'; @Injectable({ providedIn: 'root' }) @@ -26,8 +27,14 @@ export class TokenService { "login": login, "password": password } - const token = await this.http.post("https://authservice.hottis.de/token", userCreds).toPromise() - this.messageService.add(`Token is ${JSON.stringify(token, undefined, 4)}`) + const token = await this.http.post( + "https://authservice.hottis.de/token", + userCreds, + {responseType:'text'} + ).toPromise() + this.messageService.add(`Token is ${token}`) + localStorage.setItem(TokenService.Id_Token_Key, token) + this.messageService.add("Token saved") } }