@universal-packages/authentication
Advanced tools
Comparing version 1.11.2 to 1.12.0
@@ -20,3 +20,3 @@ "use strict"; | ||
const { currentEmail, email, password } = payload; | ||
return await new UpdateValidation_1.default(authentication, currentEmail, this.options).validate({ email, password }); | ||
return await new UpdateValidation_1.default({ email: currentEmail }, authentication, this.options).validate({ email, password }); | ||
} | ||
@@ -23,0 +23,0 @@ }; |
@@ -6,9 +6,8 @@ import { BaseValidation } from '@universal-packages/validations'; | ||
readonly authentication: Authentication<DefaultModuleDynamicNames>; | ||
readonly currentEmail: string; | ||
readonly options: DefaultModuleOptions; | ||
constructor(authentication: Authentication<DefaultModuleDynamicNames>, currentEmail: string, options: DefaultModuleOptions); | ||
constructor(initialValues: Record<string, any>, authentication: Authentication<DefaultModuleDynamicNames>, options: DefaultModuleOptions); | ||
emailFormat(email: string): boolean; | ||
emailSize(email: string): boolean; | ||
emailUnique(email: string): Promise<boolean>; | ||
emailUnique(email: string, initialEmail: string): Promise<boolean>; | ||
passwordLength(password: string): boolean; | ||
} |
@@ -15,6 +15,5 @@ "use strict"; | ||
class UpdateValidation extends validations_1.BaseValidation { | ||
constructor(authentication, currentEmail, options) { | ||
super(); | ||
constructor(initialValues, authentication, options) { | ||
super(initialValues); | ||
this.authentication = authentication; | ||
this.currentEmail = currentEmail; | ||
this.options = options; | ||
@@ -32,4 +31,4 @@ } | ||
} | ||
async emailUnique(email) { | ||
if (this.currentEmail === email) | ||
async emailUnique(email, initialEmail) { | ||
if (email === initialEmail) | ||
return true; | ||
@@ -36,0 +35,0 @@ return !(await this.authentication.performDynamic('user-exists-with-email?', { email })); |
{ | ||
"name": "@universal-packages/authentication", | ||
"version": "1.11.2", | ||
"version": "1.12.0", | ||
"description": "Dynamic authentication api", | ||
@@ -22,3 +22,3 @@ "author": "David De Anda <david@universal-packages.com> (https://github.com/universal-packages)", | ||
"@universal-packages/time-based-one-time-password": "^1.0.4", | ||
"@universal-packages/validations": "^1.1.1", | ||
"@universal-packages/validations": "^1.2.0", | ||
"validator": "^13.7.0" | ||
@@ -25,0 +25,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
113046
1355