feat: Implement createAuthLink mutation

This commit is contained in:
Faruk AYDIN
2021-10-14 15:17:58 +02:00
committed by Ali BARIN
parent 7f17420ae0
commit bdd0843d94
11 changed files with 130 additions and 3 deletions

View File

@@ -1,5 +1,6 @@
import { QueryContext, ModelOptions } from 'objection';
import Base from './base'
import Base from './base';
import Credential from './credential';
import bcrypt from 'bcrypt';
class User extends Base {
@@ -20,6 +21,17 @@ class User extends Base {
}
}
static relationMappings = () => ({
credentials: {
relation: Base.HasManyRelation,
modelClass: Credential,
join: {
from: 'users.id',
to: 'credentials.user_id',
},
}
})
async generateHash() {
this.password = await bcrypt.hash(this.password, 10);
}