upgrade to newest backend

This commit is contained in:
_Bastler
2021-07-22 18:45:04 +02:00
parent e6742f1cc5
commit 72178dd7c4
39 changed files with 382 additions and 705 deletions
@@ -1,25 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AccountComponent } from './account.component';
describe('AccountComponent', () => {
let component: AccountComponent;
let fixture: ComponentFixture<AccountComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ AccountComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(AccountComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -1,25 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AliasesComponent } from './aliases.component';
describe('AliasesComponent', () => {
let component: AliasesComponent;
let fixture: ComponentFixture<AliasesComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ AliasesComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(AliasesComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -1,25 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { DomainsComponent } from './domains.component';
describe('DomainsComponent', () => {
let component: DomainsComponent;
let fixture: ComponentFixture<DomainsComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ DomainsComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(DomainsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -1,25 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { InfoComponent } from './info.component';
describe('InfoComponent', () => {
let component: InfoComponent;
let fixture: ComponentFixture<InfoComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ InfoComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(InfoComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -1,25 +0,0 @@
import {ComponentFixture, TestBed} from '@angular/core/testing';
import {ProfileComponent} from './profile.component';
describe('ProfileComponent', () => {
let component: ProfileComponent;
let fixture: ComponentFixture<ProfileComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ProfileComponent]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(ProfileComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -1,25 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { SecurityComponent } from './security.component';
describe('SecurityComponent', () => {
let component: SecurityComponent;
let fixture: ComponentFixture<SecurityComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ SecurityComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(SecurityComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -2,7 +2,7 @@ import {Component, OnInit, ViewChild, Inject} from '@angular/core';
import {FormBuilder, FormGroup, FormControl, Validators, NgForm} from '@angular/forms';
import {MatDialog, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material/dialog';
import {AuthService} from './../../../services/auth.service';
import {Auth2FAService} from './../../../services/auth.2fa.service';
import {UserService} from './../../../services/user.service';
import {MatchingValidator} from './../../../utils/matching.validator';
@@ -29,7 +29,7 @@ export class SecurityComponent implements OnInit {
constructor(
private formBuilder: FormBuilder,
private userService: UserService,
private authService: AuthService,
private auth2FAService: Auth2FAService,
public dialog: MatDialog) {}
ngOnInit(): void {
@@ -52,7 +52,7 @@ export class SecurityComponent implements OnInit {
})
this.authService.isTotpEnabled().subscribe(response => {
this.auth2FAService.isEnabled('totp').subscribe(response => {
this.totp = true;
}, error => {
this.totp = false;
@@ -99,7 +99,7 @@ export class SecurityComponent implements OnInit {
}
createTotp() {
this.authService.createTotp().subscribe((result: any) => {
this.auth2FAService.create('totp').subscribe((result: any) => {
const dialogRef = this.dialog.open(SecurityTotpDialog, {
closeOnNavigation: false,
disableClose: true,
@@ -108,11 +108,11 @@ export class SecurityComponent implements OnInit {
dialogRef.afterClosed().subscribe(result => {
if(result) {
this.authService.enableTotp(result).subscribe((result: any) => {
this.auth2FAService.enable('totp', result).subscribe((result: any) => {
this.totp = true;
})
} else {
this.authService.removeTotp().subscribe((result: any) => {
this.auth2FAService.remove('totp').subscribe((result: any) => {
this.totp = false;
})
}
@@ -130,7 +130,7 @@ export class SecurityComponent implements OnInit {
}
removeTotp() {
this.authService.removeTotp().subscribe((result: any) => {
this.auth2FAService.remove('totp').subscribe((result: any) => {
this.totp = false;
})
}
@@ -1,25 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { VoucherComponent } from './voucher.component';
describe('VoucherComponent', () => {
let component: VoucherComponent;
let fixture: ComponentFixture<VoucherComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ VoucherComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(VoucherComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,39 @@
<form action="{{apiUrl}}/auth/login/2fa" method="POST" #form2FA>
<mat-card>
<mat-card-content>
<h2>{{'security.2fa.external' | i18n}}<mat-icon style="font-size: 1em;">open_in_new
</mat-icon>
</h2>
<mat-error *ngIf="loginInvalid">
{{'security.2fa.invalid' | i18n}}
</mat-error>
<input id="provider" name="provider" matInput hidden [value]="selectedProvider.id">
<mat-select [(ngModel)]="selectedProvider" placeholder="{{'security.2fa.provider' | i18n}}"
[ngModelOptions]="{standalone: true}">
<mat-option *ngFor="let provider of providers" [value]="provider">
{{'security.2fa.' + provider.id | i18n}}
</mat-option>
</mat-select>
<a mat-raised-button (click)="request()"
*ngIf="selectedProvider && selectedProvider.request">{{'security.2fa.' + selectedProvider.id +
'.request'
| i18n}}</a>
<mat-form-field>
<input id="code" name="code" matInput placeholder="{{'security.2fa.code' | i18n}}" required
matAutofocus>
<mat-error>
{{'security.2fa.missing' | i18n}}
</mat-error>
</mat-form-field>
<mat-slide-toggle id="keep" name="keep" [checked]="keep">
{{'login.keepSession' | i18n}}
</mat-slide-toggle>
</mat-card-content>
<mat-card-actions>
<button type="submit" mat-raised-button color="primary" (click)="form2FA.submit()"
[disabled]="form2FA.invalid">{{'security.2fa.login' | i18n}}<mat-icon style="font-size: 1em;">
open_in_new
</mat-icon></button>
</mat-card-actions>
</mat-card>
</form>
@@ -3,20 +3,25 @@ import {ActivatedRoute, Router} from '@angular/router';
import {environment} from '../../../environments/environment';
import {Auth2FAService} from '../../services/auth.2fa.service';
@Component({
selector: 'app-form-login-totp',
templateUrl: './form-login-totp.component.html',
styleUrls: ['./form-login-totp.component.scss']
selector: 'app-form-login-2fa',
templateUrl: './form-login-2fa.component.html',
styleUrls: ['./form-login-2fa.component.scss']
})
export class FormLoginTotpComponent implements OnInit {
export class FormLogin2FAComponent implements OnInit {
loginInvalid: boolean;
keep: boolean = false;
apiUrl = environment.apiUrl;
selectedProvider = {id: "", request: false};
providers = [];
constructor(
private router: Router,
private route: ActivatedRoute) {}
private route: ActivatedRoute,
private auth2FAService: Auth2FAService) {}
async ngOnInit() {
this.route.queryParams.subscribe(params => {
@@ -29,8 +34,20 @@ export class FormLoginTotpComponent implements OnInit {
this.router.navigate([], {queryParams: {keep: null}, queryParamsHandling: 'merge'});
}
});
this.auth2FAService.getEnabled().subscribe((providers: any) => {
this.providers = providers;
if(this.providers[0]) {
this.selectedProvider = this.providers[0];
}
})
}
request() {
}
}
@@ -1,27 +0,0 @@
<form action="{{apiUrl}}/auth/login/totp" method="POST" #totpForm>
<mat-card>
<mat-card-content>
<h2>{{'security.2fa.totp.external' | i18n}}<mat-icon style="font-size: 1em;">open_in_new
</mat-icon>
</h2>
<mat-error *ngIf="loginInvalid">
{{'security.2fa.totp.invalid' | i18n}}
</mat-error>
<mat-form-field>
<input id="code" name="code" matInput placeholder="{{'security.2fa.totp.code' | i18n}}" required matAutofocus>
<mat-error>
{{'security.2fa.totp.missing' | i18n}}
</mat-error>
</mat-form-field>
<mat-slide-toggle id="keep" name="keep" [checked]="keep" >
{{'login.keepSession' | i18n}}
</mat-slide-toggle>
</mat-card-content>
<mat-card-actions>
<button type="submit" mat-raised-button color="primary" (click)="totpForm.submit()"
[disabled]="totpForm.invalid">{{'security.2fa.totp.login' | i18n}}<mat-icon style="font-size: 1em;">
open_in_new
</mat-icon></button>
</mat-card-actions>
</mat-card>
</form>
@@ -1,25 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { FormLoginTotpComponent } from './form-login-totp.component';
describe('FormLoginTotpComponent', () => {
let component: FormLoginTotpComponent;
let fixture: ComponentFixture<FormLoginTotpComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ FormLoginTotpComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(FormLoginTotpComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -1,25 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { FormLoginComponent } from './form-login.component';
describe('FormLoginComponent', () => {
let component: FormLoginComponent;
let fixture: ComponentFixture<FormLoginComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ FormLoginComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(FormLoginComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -1,25 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { InvitesComponent } from './invites.component';
describe('InvitesComponent', () => {
let component: InvitesComponent;
let fixture: ComponentFixture<InvitesComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ InvitesComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(InvitesComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -1,25 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { JitsiComponent } from './jitsi.component';
describe('JitsiComponent', () => {
let component: JitsiComponent;
let fixture: ComponentFixture<JitsiComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ JitsiComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(JitsiComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -1,25 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { LoginTotpComponent } from './login-totp.component';
describe('LoginTotpComponent', () => {
let component: LoginTotpComponent;
let fixture: ComponentFixture<LoginTotpComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ LoginTotpComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(LoginTotpComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -1,9 +1,9 @@
import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { AuthService } from '../../services/auth.service';
import { Router, ActivatedRoute } from '@angular/router';
import {Component, OnInit} from '@angular/core';
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
import {Auth2FAService} from '../../services/auth.2fa.service';
import {Router, ActivatedRoute} from '@angular/router';
import { environment } from '../../../environments/environment';
import {environment} from '../../../environments/environment';
@Component({
selector: 'app-login',
@@ -17,7 +17,7 @@ export class LoginTotpComponent implements OnInit {
public apiUrl = environment.apiUrl;
targetRoute = '/account/info';
constructor(private formBuilder: FormBuilder, private authService: AuthService, private router: Router, private route: ActivatedRoute) { }
constructor(private formBuilder: FormBuilder, private auth2FAService: Auth2FAService, private router: Router, private route: ActivatedRoute) {}
ngOnInit() {
@@ -27,7 +27,7 @@ export class LoginTotpComponent implements OnInit {
});
this.route.queryParams.subscribe(params => {
if (params['target']) {
if(params['target']) {
this.targetRoute = params['target'];
}
});
@@ -35,14 +35,8 @@ export class LoginTotpComponent implements OnInit {
async loginTotp() {
this.loginInvalid = false;
if (this.form.valid) {
const totpModel = {
code: this.form.get('code').value,
keep: this.form.get('keep').value
};
this.authService.loginTotp(totpModel).subscribe((response: any) => {
if(this.form.valid) {
this.auth2FAService.login('totp', this.form.get('code').value, this.form.get('keep').value).subscribe((response: any) => {
this.router.navigate([this.targetRoute]);
}, error => {
this.loginInvalid = true;
@@ -1,25 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { LoginComponent } from './login.component';
describe('LoginComponent', () => {
let component: LoginComponent;
let fixture: ComponentFixture<LoginComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ LoginComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(LoginComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -1,25 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { NotfoundComponent } from './notfound.component';
describe('NotfoundComponent', () => {
let component: NotfoundComponent;
let fixture: ComponentFixture<NotfoundComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ NotfoundComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(NotfoundComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -1,25 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { PasswordResetComponent } from './password-reset.component';
describe('PasswordResetComponent', () => {
let component: PasswordResetComponent;
let fixture: ComponentFixture<PasswordResetComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ PasswordResetComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(PasswordResetComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -1,25 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { PasswordComponent } from './password.component';
describe('PasswordComponent', () => {
let component: PasswordComponent;
let fixture: ComponentFixture<PasswordComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ PasswordComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(PasswordComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -1,25 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { RegisterComponent } from './register.component';
describe('RegisterComponent', () => {
let component: RegisterComponent;
let fixture: ComponentFixture<RegisterComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ RegisterComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(RegisterComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -1,25 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ServicesComponent } from './services.component';
describe('ServicesComponent', () => {
let component: ServicesComponent;
let fixture: ComponentFixture<ServicesComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ServicesComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(ServicesComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -1,25 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { TokensComponent } from './tokens.component';
describe('TokensComponent', () => {
let component: TokensComponent;
let fixture: ComponentFixture<TokensComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ TokensComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(TokensComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -1,25 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { UnavailableComponent } from './unavailable.component';
describe('UnavailableComponent', () => {
let component: UnavailableComponent;
let fixture: ComponentFixture<UnavailableComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ UnavailableComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(UnavailableComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
+1 -1
View File
@@ -2,7 +2,7 @@
<mat-progress-bar *ngIf="!success && !error" mode="indeterminate"></mat-progress-bar>
<div *ngIf="success">
<h3>{{model.username}}</h3>
<h3>{{model.username}} <small *ngIf="isMe">{{'user.isMe' | i18n}}</small></h3>
<app-profilefields [username]="model.username"></app-profilefields>
<div *ngIf="model.aliases && model.aliases.length > 0">
<h4>{{'user.aliases' | i18n}}</h4>
-25
View File
@@ -1,25 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { UserComponent } from './user.component';
describe('UserComponent', () => {
let component: UserComponent;
let fixture: ComponentFixture<UserComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ UserComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(UserComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
+9
View File
@@ -2,6 +2,7 @@ import {Component, OnInit} from '@angular/core';
import {ActivatedRoute} from '@angular/router';
import {AuthService} from '../../services/auth.service';
import {ProfileService} from '../../services/profile.service';
@Component({
@@ -14,8 +15,10 @@ export class UserComponent implements OnInit {
model: any;
error = false;
success = false;
isMe = false;
constructor(
private authService: AuthService,
private profileService: ProfileService,
private route: ActivatedRoute) {}
@@ -27,6 +30,12 @@ export class UserComponent implements OnInit {
}, error => {
this.error = error;
})
this.authService.auth.subscribe((auth: any) => {
this.isMe = auth && auth.principal && auth.principal.username == this.username;
console.log(this.isMe, auth);
});
}