update
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
<form [formGroup]="form" (ngSubmit)="passwordReset()">
|
||||
<mat-card>
|
||||
<mat-card-content>
|
||||
<h2>{{'password.request' | i18n}}</h2>
|
||||
<mat-form-field>
|
||||
<input matInput placeholder="{{'username' | i18n}}" formControlName="username" [(ngModel)]="model.username">
|
||||
<mat-error>
|
||||
{{'username.missing' | i18n}}
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field>
|
||||
<mat-label>{{'pgp-key.private' | i18n}}</mat-label>
|
||||
<textarea matInput formControlName="privateKey" placeholder="Private Key"
|
||||
[(ngModel)]="model.privateKey"></textarea>
|
||||
</mat-form-field>
|
||||
</mat-card-content>
|
||||
<mat-card-actions>
|
||||
<button *ngIf="!working" mat-raised-button color="primary" [disabled]="form.invalid">
|
||||
{{'password.reset' | i18n}}
|
||||
</button>
|
||||
</mat-card-actions>
|
||||
</mat-card>
|
||||
</form>
|
||||
@@ -0,0 +1,3 @@
|
||||
mat-form-field {
|
||||
display: block;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
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();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,52 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
|
||||
import { AuthService } from './../../services/auth.service';
|
||||
import { MatchingValidator } from './../../utils/matching.validator';
|
||||
|
||||
var openpgp = require('openpgp');
|
||||
@Component({
|
||||
selector: 'app-password',
|
||||
templateUrl: './password.component.html',
|
||||
styleUrls: ['./password.component.scss']
|
||||
})
|
||||
export class PasswordComponent implements OnInit {
|
||||
|
||||
model: any = {};
|
||||
public working: boolean;
|
||||
form: FormGroup;
|
||||
|
||||
constructor(private formBuilder: FormBuilder, private authService: AuthService) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
this.form = this.formBuilder.group({
|
||||
username: ['', Validators.required],
|
||||
privateKey: ['', Validators.required]
|
||||
});
|
||||
}
|
||||
|
||||
async passwordReset() {
|
||||
const { keys: [privateKey] } = await openpgp.key.readArmored(this.model.privateKey);
|
||||
|
||||
|
||||
console.log(privateKey.isPrivate());
|
||||
|
||||
const model = {
|
||||
username: this.model.username
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
const message = await openpgp.message.readArmored(encrypted);
|
||||
|
||||
const decrypted = await openpgp.decrypt({
|
||||
message: message,
|
||||
privateKeys: [privateKey]
|
||||
});
|
||||
|
||||
console.log(decrypted);
|
||||
// this.authService.passwordReset(model).subscribe(async response => { })
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user