test(user): write tests for $beforeInsert and $beforeUpdate
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
Reference in New Issue
Block a user