Merge branch 'develop'

This commit is contained in:
Alice Gaudon 2020-11-04 12:06:25 +01:00
commit 444599cdfa
4 changed files with 22 additions and 9 deletions

View File

@ -1,6 +1,6 @@
{
"name": "rainbox.email",
"version": "2.0.1",
"version": "2.0.2",
"description": "ISP mail provider manager with mysql and integrated LDAP server",
"repository": "https://gitlab.com/ArisuOngaku/rainbox.email",
"author": "Alice Gaudon <alice@gaudon.pro>",

View File

@ -88,8 +88,6 @@ export default class AuthController extends _AuthController {
try {
await this.getApp().as(AuthComponent).getAuthGuard().authenticateOrRegister(req.session, passwordAuthProof,
undefined, async (connection, user) => {
passwordAuthProof.setResource(user);
const callbacks: RegisterCallback[] = [];
// Password
@ -99,6 +97,9 @@ export default class AuthController extends _AuthController {
user.as(UserNameComponent).name = req.body.username;
return callbacks;
}, async (connection, user) => {
passwordAuthProof.setResource(user);
return [];
});
} catch (e) {
if (e instanceof PendingApprovalAuthError) {

View File

@ -38,6 +38,7 @@ export class PasswordAuthProof implements AuthProof<User> {
public static createAuthorizedProofForRegistration(session: Express.Session): PasswordAuthProof {
const proofForSession = new PasswordAuthProof(session);
proofForSession.authorized = true;
proofForSession.forRegistration = true;
proofForSession.save();
return proofForSession;
}
@ -47,13 +48,15 @@ export class PasswordAuthProof implements AuthProof<User> {
}
private readonly session: Express.Session;
private userId: number | null;
private authorized: boolean;
private forRegistration: boolean = false;
private userId: number | null;
private userPassword: UserPasswordComponent | null = null;
private constructor(session: Express.Session) {
this.session = session;
this.authorized = session.auth_password_proof?.authorized || false;
this.forRegistration = session.auth_password_proof?.forRegistration || false;
this.userId = session.auth_password_proof?.userId || null;
}
@ -72,7 +75,8 @@ export class PasswordAuthProof implements AuthProof<User> {
}
public async isValid(): Promise<boolean> {
return Boolean(await this.getResource());
return (this.forRegistration || Boolean(await this.getResource())) &&
await this.isAuthorized();
}
public async revoke(): Promise<void> {
@ -98,6 +102,7 @@ export class PasswordAuthProof implements AuthProof<User> {
private save() {
this.session.auth_password_proof = {
authorized: this.authorized,
forRegistration: this.forRegistration,
userId: this.userId,
};
}

View File

@ -798,13 +798,20 @@
"@babel/types" "^7.4.4"
esutils "^2.0.2"
"@babel/runtime@^7.8.4", "@babel/runtime@^7.8.7":
"@babel/runtime@^7.8.4":
version "7.12.1"
resolved "https://registry.npmjs.org/@babel/runtime/-/runtime-7.12.1.tgz#b4116a6b6711d010b2dad3b7b6e43bf1b9954740"
integrity sha512-J5AIf3vPj3UwXaAzb5j1xM4WAQDX3EMgemF8rjCP3SoW09LfRKAXQKt6CoVYl230P6iWdRcBbnLDDdnqWxZSCA==
dependencies:
regenerator-runtime "^0.13.4"
"@babel/runtime@^7.8.7":
version "7.12.5"
resolved "https://registry.npmjs.org/@babel/runtime/-/runtime-7.12.5.tgz#410e7e487441e1b360c29be715d870d9b985882e"
integrity sha512-plcc+hbExy3McchJCEQG3knOsuh3HH+Prx1P6cLIkET/0dLuQDEnrT+s27Axgc9bqfsmNUNHfscgMUdBpC9xfg==
dependencies:
regenerator-runtime "^0.13.4"
"@babel/template@^7.10.4", "@babel/template@^7.3.3":
version "7.10.4"
resolved "https://registry.npmjs.org/@babel/template/-/template-7.10.4.tgz#3251996c4200ebc71d1a8fc405fba940f36ba278"
@ -9387,9 +9394,9 @@ widest-line@^3.1.0:
string-width "^4.0.0"
wms-core@^0.22.0:
version "0.22.4"
resolved "https://registry.npmjs.org/wms-core/-/wms-core-0.22.4.tgz#220d94573add450758ab42dac0579dd2b0322277"
integrity sha512-tR8dbAVjRih9maeNVaHoBSNpXN1ctZ0G9jOASIIG9L6a/S011gGXTJCPhwNu9lzzMbeqxrgSF+LgJVfE2aml+g==
version "0.22.5"
resolved "https://registry.npmjs.org/wms-core/-/wms-core-0.22.5.tgz#7967cb63cf278e00a3cd05399502b72a90a4590a"
integrity sha512-2XnvNytgirZFpEmiB9WH6xQGr3ANhlMC85sZThdtkADVE1FFJqXVQ1V+F00SnChJvXvm5+5cT3T+lpm0pfrC1A==
dependencies:
argon2 "^0.27.0"
compression "^1.7.4"