This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Injectable} from "@angular/core"; | |
import {HttpEvent, HttpHandler, HttpInterceptor, HttpRequest} from "@angular/common/http"; | |
import {Observable} from 'rxjs'; | |
@Injectable() | |
export class TokenInterceptorService implements HttpInterceptor { | |
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { | |
request = request.clone({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Injectable} from '@angular/core'; | |
import {isNullOrUndefined} from "util"; | |
import {HttpClient} from "@angular/common/http"; | |
import * as decode from 'jwt-decode'; | |
import {retry} from 'rxjs/operators'; | |
//npm install --save-dev jwt-decode | |
interface User { | |
result: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div *ngIf="!isLoggedIn()"> | |
<h1>Login</h1> | |
<form class="ui large form" [formGroup]="loginForm" (ngSubmit)="login()"> | |
<div class="field"> | |
<label>E-Mail</label> | |
<input type="email" id="username" formControlName="username"> | |
<div *ngIf="loginForm.get('username').invalid && | |
(loginForm.get('username').dirty || loginForm.get('username').touched) && | |
loginForm.get('username').hasError('required')" class="ui negative message"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "laravel/laravel", | |
"description": "The Laravel Framework.", | |
"keywords": ["framework", "laravel"], | |
"license": "MIT", | |
"type": "project", | |
"require": { | |
"php": ">=7.0.0", | |
"barryvdh/laravel-cors": "^0.11.3", | |
"fideloper/proxy": "~3.3", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controllers\Auth; | |
use Illuminate\Http\Request; | |
use App\Http\Controllers\Controller; | |
use App\Http\Requests; | |
use JWTAuth; | |
use JWTAuthException; | |
use App\User; | |
class ApiAuthController extends Controller | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class ErrorMessage { | |
constructor( | |
public forControl: string, | |
public forValidator: string, | |
public text: string | |
) { } | |
} | |
export const BookFormErrorMessages = [ | |
new ErrorMessage('title', 'required', 'Ein Buchtitel muss angegeben werden'), | |
new ErrorMessage('isbn', 'required', 'Es muss eine ISBN angegeben werden'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ActivatedRoute, Router } from '@angular/router'; | |
import { Component, OnInit } from '@angular/core'; | |
import { FormBuilder, FormGroup, FormArray, Validators } from '@angular/forms'; | |
import { BookFormErrorMessages } from './book-form-error-messages'; | |
import {BookFactory} from "../shared/book-factory"; | |
import {BookStoreService} from "../shared/book-store.service"; | |
import {Book, Image} from "../shared/book"; | |
@Component({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>Buchformular</h1> | |
<form class="ui large form" [formGroup]="bookForm" (ngSubmit)="submitForm()"> | |
<input type="hidden" name="id"> | |
<div class="field"> | |
<label>Buchtitel</label> | |
<input formControlName="title"> | |
<div *ngIf="errors.title" class="ui negative message"> {{ errors.title }} </div> | |
</div> | |
<div class="field"> | |
<label>Untertitel</label> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Book } from './book'; | |
export class BookFactory { | |
static empty(): Book { | |
return new Book(null, '', '', [], new Date(),0, '', 0, [{id: 0, url: '', title: ''}], ''); | |
} | |
static fromObject(rawBook: any): Book { | |
return new Book( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { NgModule } from '@angular/core'; | |
import {Routes, RouterModule} from '@angular/router'; | |
import { BookDetailsComponent } from './book-details/book-details.component'; | |
import { BookListComponent } from './book-list/book-list.component'; | |
import { HomeComponent } from './home/home.component'; | |
const routes: Routes = [ | |
{ path: '', redirectTo: 'home', pathMatch: 'full' }, | |
{ path: 'home', component: HomeComponent }, |