parent
63dc06ab31
commit
55dc97e672
|
@ -47,7 +47,7 @@ export default class AuthController extends Controller {
|
|||
private async postRegister(req: Request, res: Response): Promise<void> {
|
||||
const validationMap: any = {
|
||||
password: new Validator().defined().minLength(8),
|
||||
password_confirmation: new Validator().defined().equals(req.body.password),
|
||||
password_confirmation: new Validator().defined().sameAs('password', req.body.password),
|
||||
terms: new Validator().defined(),
|
||||
};
|
||||
|
||||
|
@ -55,10 +55,11 @@ export default class AuthController extends Controller {
|
|||
if (req.body.create_email) {
|
||||
validationMap['username'] = new Validator().defined().minLength(3).regexp(/^[0-9a-zA-Z_-]+$/);
|
||||
validationMap['domain'] = new Validator().defined().regexp(/^(toot\.party)$/);
|
||||
validationMap['recovery_email'] = new Validator().acceptUndefined().regexp(EMAIL_REGEX);
|
||||
email = req.body.username + '@' + req.body.domain;
|
||||
validationMap['recovery_email'] = new Validator().acceptUndefined().regexp(EMAIL_REGEX).unique(UserEmail, 'email');
|
||||
email = req.body.email = req.body.username + '@' + req.body.domain;
|
||||
validationMap['email'] = new Validator().defined().regexp(EMAIL_REGEX).unique(UserEmail, 'email');
|
||||
} else {
|
||||
validationMap['recovery_email'] = new Validator().defined().regexp(EMAIL_REGEX);
|
||||
validationMap['recovery_email'] = new Validator().defined().regexp(EMAIL_REGEX).unique(UserEmail, 'email');
|
||||
email = req.body.recovery_email;
|
||||
}
|
||||
await this.validate(validationMap, req.body);
|
||||
|
|
|
@ -3,6 +3,7 @@ import Validator from "wms-core/db/Validator";
|
|||
import User from "wms-core/auth/models/User";
|
||||
import argon2 from "argon2";
|
||||
import AuthProof from "wms-core/auth/AuthProof";
|
||||
import {UserAlreadyExistsAuthError} from "wms-core/auth/AuthGuard";
|
||||
|
||||
export default class UserPassword extends Model {
|
||||
public static async getByEmail(email: string): Promise<UserPassword | null> {
|
||||
|
@ -100,7 +101,7 @@ export class PasswordAuthProof implements AuthProof {
|
|||
}
|
||||
|
||||
public async register(password: string): Promise<UserPassword> {
|
||||
if (await this.getUserPassword()) throw new Error(`Cannot register; I already have a user.`);
|
||||
if (await this.getUserPassword()) throw new UserAlreadyExistsAuthError(await this.getEmail());
|
||||
this.userPassword = new UserPassword({});
|
||||
await this.userPassword.setPassword(password);
|
||||
return this.userPassword;
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
<span>@</span>
|
||||
{{ macros.field(_locals, 'select', 'domain', null, 'Choose your domain', null, 'disabled', ['toot.party']) }}
|
||||
</div>
|
||||
{{ macros.fieldError(_locals, 'email') }}
|
||||
</section>
|
||||
|
||||
<section class="sub-panel">
|
||||
|
|
|
@ -9798,9 +9798,9 @@ widest-line@^3.1.0:
|
|||
string-width "^4.0.0"
|
||||
|
||||
wms-core@^0:
|
||||
version "0.4.7"
|
||||
resolved "http://127.0.0.1:4873/wms-core/-/wms-core-0.4.7.tgz#42ee3d3c87bcad2c490644bb3bcf826bd3d18e66"
|
||||
integrity sha512-gvO0oI6m0dKxvubk4s0ZowfPXAC5dIV6y38K4ztwI3d3OdBPsiA/3TFmxAzIe97eWmx0yczRPL9GQuHbovXYlA==
|
||||
version "0.4.15"
|
||||
resolved "http://127.0.0.1:4873/wms-core/-/wms-core-0.4.15.tgz#3b4ef49cbf1bcf24b52c337439c71f361665a5bf"
|
||||
integrity sha512-YoAsdJ69himgb3dT+6+aildMShFQJAD8yhQGQJNhY32RmAbl3C2z0xIhBy1kL/YAzypqZQxvBYZS14f/qd94QQ==
|
||||
dependencies:
|
||||
"@types/express" "^4.17.6"
|
||||
"@types/express-session" "^1.17.0"
|
||||
|
|
Loading…
Reference in New Issue