Update api client and add redirects after logging in and on "/"
This commit is contained in:
@ -4,6 +4,7 @@ import {SigningComponent} from './components/signing/signing.component';
|
|||||||
import {LoginComponent} from './components/login/login.component';
|
import {LoginComponent} from './components/login/login.component';
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
|
{path: "", redirectTo: "signing-request/a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11", pathMatch: "full"},
|
||||||
{path: "login", component: LoginComponent},
|
{path: "login", component: LoginComponent},
|
||||||
{path: "signing-request/:id", component: SigningComponent}
|
{path: "signing-request/:id", component: SigningComponent}
|
||||||
];
|
];
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import {Component} from '@angular/core';
|
import {Component, OnInit} from '@angular/core';
|
||||||
import {CreateSessionRequest, CreateSessionResponse, SessionService} from '../../../gen';
|
import {CreateSessionRequest, CreateSessionResponse, TokenService} from '../../../gen';
|
||||||
import {AuthService} from '../../services/auth.service';
|
import {AuthService} from '../../services/auth.service';
|
||||||
|
import {Router} from '@angular/router';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-login',
|
selector: 'app-login',
|
||||||
@ -9,19 +10,26 @@ import {AuthService} from '../../services/auth.service';
|
|||||||
templateUrl: './login.component.html',
|
templateUrl: './login.component.html',
|
||||||
styleUrl: './login.component.css'
|
styleUrl: './login.component.css'
|
||||||
})
|
})
|
||||||
export class LoginComponent {
|
export class LoginComponent implements OnInit {
|
||||||
createSessionRequest: CreateSessionRequest = {
|
createSessionRequest: CreateSessionRequest = {
|
||||||
username: "",
|
username: "",
|
||||||
password: ""
|
password: ""
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(private sessionService: SessionService, private authService: AuthService) {
|
constructor(private tokenService: TokenService, private authService: AuthService, private router: Router) {
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
if (this.authService.getToken() != null) {
|
||||||
|
this.router.navigate(["/"]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onSubmit(): void {
|
onSubmit(): void {
|
||||||
this.sessionService.createToken(this.createSessionRequest).subscribe({
|
this.tokenService.createToken(this.createSessionRequest).subscribe({
|
||||||
next: (response: CreateSessionResponse): void => {
|
next: (response: CreateSessionResponse): void => {
|
||||||
this.authService.setToken(response.token);
|
this.authService.setToken(response.token);
|
||||||
|
this.router.navigate(["/"]);
|
||||||
},
|
},
|
||||||
error: (err: Error): void => {
|
error: (err: Error): void => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
.gitignore
|
.gitignore
|
||||||
|
.openapi-generator-ignore
|
||||||
README.md
|
README.md
|
||||||
api.module.ts
|
api.module.ts
|
||||||
api/api.ts
|
api/api.ts
|
||||||
api/hello.service.ts
|
|
||||||
api/session.service.ts
|
|
||||||
api/signingRequest.service.ts
|
api/signingRequest.service.ts
|
||||||
api/signingRequestDocument.service.ts
|
api/signingRequestDocument.service.ts
|
||||||
|
api/token.service.ts
|
||||||
configuration.ts
|
configuration.ts
|
||||||
encoder.ts
|
encoder.ts
|
||||||
git_push.sh
|
git_push.sh
|
||||||
@ -15,7 +15,6 @@ model/createSessionResponse.ts
|
|||||||
model/errorResponse.ts
|
model/errorResponse.ts
|
||||||
model/getSigningRequestResponse.ts
|
model/getSigningRequestResponse.ts
|
||||||
model/getSigningRequestResponseSigningRequestDocument.ts
|
model/getSigningRequestResponseSigningRequestDocument.ts
|
||||||
model/helloResponse.ts
|
|
||||||
model/models.ts
|
model/models.ts
|
||||||
model/patchOperation.ts
|
model/patchOperation.ts
|
||||||
param.ts
|
param.ts
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
export * from './hello.service';
|
|
||||||
import { HelloService } from './hello.service';
|
|
||||||
export * from './session.service';
|
|
||||||
import { SessionService } from './session.service';
|
|
||||||
export * from './signingRequest.service';
|
export * from './signingRequest.service';
|
||||||
import { SigningRequestService } from './signingRequest.service';
|
import { SigningRequestService } from './signingRequest.service';
|
||||||
export * from './signingRequestDocument.service';
|
export * from './signingRequestDocument.service';
|
||||||
import { SigningRequestDocumentService } from './signingRequestDocument.service';
|
import { SigningRequestDocumentService } from './signingRequestDocument.service';
|
||||||
export const APIS = [HelloService, SessionService, SigningRequestService, SigningRequestDocumentService];
|
export * from './token.service';
|
||||||
|
import { TokenService } from './token.service';
|
||||||
|
export const APIS = [SigningRequestService, SigningRequestDocumentService, TokenService];
|
||||||
|
@ -1,153 +0,0 @@
|
|||||||
/**
|
|
||||||
* swisssign-challenge - dlmw
|
|
||||||
*
|
|
||||||
* Contact: dylan@dlmw.ch
|
|
||||||
*
|
|
||||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
||||||
* https://openapi-generator.tech
|
|
||||||
* Do not edit the class manually.
|
|
||||||
*/
|
|
||||||
/* tslint:disable:no-unused-variable member-ordering */
|
|
||||||
|
|
||||||
import { Inject, Injectable, Optional } from '@angular/core';
|
|
||||||
import { HttpClient, HttpHeaders, HttpParams,
|
|
||||||
HttpResponse, HttpEvent, HttpParameterCodec, HttpContext
|
|
||||||
} from '@angular/common/http';
|
|
||||||
import { CustomHttpParameterCodec } from '../encoder';
|
|
||||||
import { Observable } from 'rxjs';
|
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
import { HelloResponse } from '../model/helloResponse';
|
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
import { BASE_PATH, COLLECTION_FORMATS } from '../variables';
|
|
||||||
import { Configuration } from '../configuration';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Injectable({
|
|
||||||
providedIn: 'root'
|
|
||||||
})
|
|
||||||
export class HelloService {
|
|
||||||
|
|
||||||
protected basePath = 'http://localhost';
|
|
||||||
public defaultHeaders = new HttpHeaders();
|
|
||||||
public configuration = new Configuration();
|
|
||||||
public encoder: HttpParameterCodec;
|
|
||||||
|
|
||||||
constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string|string[], @Optional() configuration: Configuration) {
|
|
||||||
if (configuration) {
|
|
||||||
this.configuration = configuration;
|
|
||||||
}
|
|
||||||
if (typeof this.configuration.basePath !== 'string') {
|
|
||||||
const firstBasePath = Array.isArray(basePath) ? basePath[0] : undefined;
|
|
||||||
if (firstBasePath != undefined) {
|
|
||||||
basePath = firstBasePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof basePath !== 'string') {
|
|
||||||
basePath = this.basePath;
|
|
||||||
}
|
|
||||||
this.configuration.basePath = basePath;
|
|
||||||
}
|
|
||||||
this.encoder = this.configuration.encoder || new CustomHttpParameterCodec();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
private addToHttpParams(httpParams: HttpParams, value: any, key?: string): HttpParams {
|
|
||||||
if (typeof value === "object" && value instanceof Date === false) {
|
|
||||||
httpParams = this.addToHttpParamsRecursive(httpParams, value);
|
|
||||||
} else {
|
|
||||||
httpParams = this.addToHttpParamsRecursive(httpParams, value, key);
|
|
||||||
}
|
|
||||||
return httpParams;
|
|
||||||
}
|
|
||||||
|
|
||||||
private addToHttpParamsRecursive(httpParams: HttpParams, value?: any, key?: string): HttpParams {
|
|
||||||
if (value == null) {
|
|
||||||
return httpParams;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof value === "object") {
|
|
||||||
if (Array.isArray(value)) {
|
|
||||||
(value as any[]).forEach( elem => httpParams = this.addToHttpParamsRecursive(httpParams, elem, key));
|
|
||||||
} else if (value instanceof Date) {
|
|
||||||
if (key != null) {
|
|
||||||
httpParams = httpParams.append(key, (value as Date).toISOString().substring(0, 10));
|
|
||||||
} else {
|
|
||||||
throw Error("key may not be null if value is Date");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Object.keys(value).forEach( k => httpParams = this.addToHttpParamsRecursive(
|
|
||||||
httpParams, value[k], key != null ? `${key}.${k}` : k));
|
|
||||||
}
|
|
||||||
} else if (key != null) {
|
|
||||||
httpParams = httpParams.append(key, value);
|
|
||||||
} else {
|
|
||||||
throw Error("key may not be null if value is not object or array");
|
|
||||||
}
|
|
||||||
return httpParams;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a hello from me
|
|
||||||
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
|
||||||
* @param reportProgress flag to report request and response progress.
|
|
||||||
*/
|
|
||||||
public getHello(observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HelloResponse>;
|
|
||||||
public getHello(observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<HelloResponse>>;
|
|
||||||
public getHello(observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<HelloResponse>>;
|
|
||||||
public getHello(observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
|
|
||||||
|
|
||||||
let localVarHeaders = this.defaultHeaders;
|
|
||||||
|
|
||||||
let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
|
|
||||||
if (localVarHttpHeaderAcceptSelected === undefined) {
|
|
||||||
// to determine the Accept header
|
|
||||||
const httpHeaderAccepts: string[] = [
|
|
||||||
'application/json'
|
|
||||||
];
|
|
||||||
localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
|
||||||
}
|
|
||||||
if (localVarHttpHeaderAcceptSelected !== undefined) {
|
|
||||||
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
|
|
||||||
}
|
|
||||||
|
|
||||||
let localVarHttpContext: HttpContext | undefined = options && options.context;
|
|
||||||
if (localVarHttpContext === undefined) {
|
|
||||||
localVarHttpContext = new HttpContext();
|
|
||||||
}
|
|
||||||
|
|
||||||
let localVarTransferCache: boolean | undefined = options && options.transferCache;
|
|
||||||
if (localVarTransferCache === undefined) {
|
|
||||||
localVarTransferCache = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
let responseType_: 'text' | 'json' | 'blob' = 'json';
|
|
||||||
if (localVarHttpHeaderAcceptSelected) {
|
|
||||||
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
|
|
||||||
responseType_ = 'text';
|
|
||||||
} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
|
|
||||||
responseType_ = 'json';
|
|
||||||
} else {
|
|
||||||
responseType_ = 'blob';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let localVarPath = `/hello`;
|
|
||||||
return this.httpClient.request<HelloResponse>('get', `${this.configuration.basePath}${localVarPath}`,
|
|
||||||
{
|
|
||||||
context: localVarHttpContext,
|
|
||||||
responseType: <any>responseType_,
|
|
||||||
withCredentials: this.configuration.withCredentials,
|
|
||||||
headers: localVarHeaders,
|
|
||||||
observe: observe,
|
|
||||||
transferCache: localVarTransferCache,
|
|
||||||
reportProgress: reportProgress
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -32,7 +32,7 @@ import { Configuration } from '../configurat
|
|||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class SessionService {
|
export class TokenService {
|
||||||
|
|
||||||
protected basePath = 'http://localhost';
|
protected basePath = 'http://localhost';
|
||||||
public defaultHeaders = new HttpHeaders();
|
public defaultHeaders = new HttpHeaders();
|
@ -18,9 +18,5 @@ export interface ErrorResponse {
|
|||||||
* Machine-readable error code
|
* Machine-readable error code
|
||||||
*/
|
*/
|
||||||
code: number;
|
code: number;
|
||||||
/**
|
|
||||||
* Additional error details when available
|
|
||||||
*/
|
|
||||||
details?: object;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
/**
|
|
||||||
* swisssign-challenge - dlmw
|
|
||||||
*
|
|
||||||
* Contact: dylan@dlmw.ch
|
|
||||||
*
|
|
||||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
||||||
* https://openapi-generator.tech
|
|
||||||
* Do not edit the class manually.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
export interface HelloResponse {
|
|
||||||
value?: string;
|
|
||||||
}
|
|
||||||
|
|
@ -3,5 +3,4 @@ export * from './createSessionResponse';
|
|||||||
export * from './errorResponse';
|
export * from './errorResponse';
|
||||||
export * from './getSigningRequestResponse';
|
export * from './getSigningRequestResponse';
|
||||||
export * from './getSigningRequestResponseSigningRequestDocument';
|
export * from './getSigningRequestResponseSigningRequestDocument';
|
||||||
export * from './helloResponse';
|
|
||||||
export * from './patchOperation';
|
export * from './patchOperation';
|
||||||
|
Reference in New Issue
Block a user