Skip to content
Snippets Groups Projects
Verified Commit 845fa7be authored by Lukas Maximilian Kimpel's avatar Lukas Maximilian Kimpel
Browse files

Create empty httpHeaders to be able to send post request

Reformat code
parent 703a4e24
Branches
Tags
No related merge requests found
......@@ -4,7 +4,7 @@ import { Observable } from 'rxjs/Observable';
import { of } from 'rxjs/observable/of';
import { UserRole } from './user-roles.enum';
import { DataStoreService } from './data-store.service';
import { HttpClient } from '@angular/common/http';
import { HttpClient, HttpHeaders } from '@angular/common/http';
// TODO: connect to API
// TODO: persist user data (shouldn't get lost on page refresh)
......@@ -15,6 +15,9 @@ export class AuthenticationService {
private apiBaseUrl = 'https://arsnova-staging.mni.thm.de/api';
private apiAuthUrl = '/auth';
private apiLoginUrl = '/login';
private httpHeaders = new HttpHeaders({
});
constructor(private dataStoreService: DataStoreService,
private http: HttpClient) {
......@@ -33,7 +36,7 @@ export class AuthenticationService {
}
guestLogin() {
this.http.get<string>(this.apiBaseUrl + this.apiAuthUrl + this.apiLoginUrl + '/guest').subscribe(token => {
this.http.post<string>(this.apiBaseUrl + this.apiAuthUrl + this.apiLoginUrl + '/guest', this.httpHeaders).subscribe(token => {
if (token != null) {
this.user = new User(1337, '', '', UserRole.PARTICIPANT, token);
return of(true);
......
......@@ -14,7 +14,5 @@
<mat-error *ngIf="passwordFormControl.hasError('required')">Password is <strong>required</strong>.</mat-error>
</mat-form-field>
<button mat-raised-button color="primary" type="submit">Login</button>
<button mat-raised-button *ngIf="role === UserRole.PARTICIPANT" (click)="guestLogin()">Login as
guest
</button>
<button mat-raised-button *ngIf="role === UserRole.PARTICIPANT" (click)="guestLogin()">Login as guest</button>
</form>
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment