fix registration

This commit is contained in:
_Bastler 2022-11-24 12:41:04 +01:00
parent 88bd69cbc6
commit 7391ff1147

View File

@ -19,7 +19,7 @@ var openpgp = require('openpgp');
@Component({
selector: 'app-register',
templateUrl: './register.component.html',
styleUrls: [ './register.component.scss' ]
styleUrls: ['./register.component.scss']
})
export class RegisterComponent implements OnInit {
@ -51,11 +51,11 @@ export class RegisterComponent implements OnInit {
async ngOnInit() {
this.form = this.formBuilder.group({
username: [ '', Validators.required ],
email: [ '', Validators.email ],
primaryEmail: [ false, Validators.nullValidator ],
password: [ '', Validators.nullValidator ],
password2: [ '', Validators.required ]
username: ['', Validators.required],
email: ['', Validators.email],
primaryEmail: [false, Validators.nullValidator],
password: ['', Validators.nullValidator],
password2: ['', Validators.required]
}, {
validator: MatchingValidator('password', 'password2')
});
@ -84,7 +84,7 @@ export class RegisterComponent implements OnInit {
mailControl.clearAsyncValidators();
mailControl.clearValidators();
if (this.model.primaryEmail) {
mailControl.setValidators([ Validators.email, Validators.required ]);
mailControl.setValidators([Validators.email, Validators.required]);
}
mailControl.updateValueAndValidity();
}
@ -92,7 +92,7 @@ export class RegisterComponent implements OnInit {
genUsername() {
const config: Config = {
dictionaries: [ adjectives, colors, animals ],
dictionaries: [adjectives, colors, animals],
separator: "",
style: "capital",
length: 3
@ -107,14 +107,14 @@ export class RegisterComponent implements OnInit {
if (this.form.valid && !this.working) {
this.working = true;
let pgpOption = {
userIds: [ { name: this.model.username, email: this.model.username + "@we.bstly.de" } ],
userIDs: [{ name: this.model.username, email: this.model.username + "@we.bstly.de" }],
curve: "ed25519",
}
var pubKey, privKey
openpgp.generateKey(pgpOption).then((key) => {
privKey = key.privateKeyArmored;
pubKey = key.publicKeyArmored;
privKey = key.privateKey;
pubKey = key.publicKey;
this.model.profileFields = [
{ "name": "publicKey", "type": "BLOB", "visibility": "PROTECTED", "blob": pubKey }
@ -154,12 +154,13 @@ export class RegisterComponent implements OnInit {
} else if (error.status == 409) {
let errors = {};
for (let code of error.error) {
errors[ code.field ] = errors[ code.field ] || {};
errors[ code.field ][ code.code ] = true;
errors[code.field] = errors[code.field] || {};
errors[code.field][code.code] = true;
}
for (let code in errors) {
this.form.get(code).setErrors(errors[ code ]);
console.warn(code, errors[code]);
this.form.get(code).setErrors(errors[code]);
}
}
}
@ -174,7 +175,7 @@ export class RegisterComponent implements OnInit {
@Component({
selector: 'app-register-dialog',
templateUrl: 'register.dialog.html',
styleUrls: [ './register.dialog.scss' ]
styleUrls: ['./register.dialog.scss']
})
export class RegisterDialog {