test(user): write tests for $beforeInsert and $beforeUpdate

This commit is contained in:
Ali BARIN
2024-11-20 11:02:55 +00:00
committed by Faruk AYDIN
parent fb53e37f7a
commit 807faa3c93
2 changed files with 117 additions and 4 deletions

View File

@@ -602,10 +602,17 @@ class User extends Base {
return conditionMap;
}
lowercaseEmail() {
if (this.email) {
this.email = this.email.toLowerCase();
}
}
g;
async $beforeInsert(queryContext) {
await super.$beforeInsert(queryContext);
this.email = this.email.toLowerCase();
this.lowercaseEmail();
await this.generateHash();
if (appConfig.isCloud) {
@@ -616,9 +623,7 @@ class User extends Base {
async $beforeUpdate(opt, queryContext) {
await super.$beforeUpdate(opt, queryContext);
if (this.email) {
this.email = this.email.toLowerCase();
}
this.lowercaseEmail();
await this.generateHash();
}