diff options
Diffstat (limited to 'app/Models/User.js')
-rw-r--r-- | app/Models/User.js | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/app/Models/User.js b/app/Models/User.js index c9a680a..3a40347 100644 --- a/app/Models/User.js +++ b/app/Models/User.js | |||
@@ -1,14 +1,13 @@ | |||
1 | 'use strict' | ||
2 | 1 | ||
3 | /** @type {typeof import('@adonisjs/lucid/src/Lucid/Model')} */ | 2 | /** @type {typeof import('@adonisjs/lucid/src/Lucid/Model')} */ |
4 | const Model = use('Model') | 3 | const Model = use('Model'); |
5 | 4 | ||
6 | /** @type {import('@adonisjs/framework/src/Hash')} */ | 5 | /** @type {import('@adonisjs/framework/src/Hash')} */ |
7 | const Hash = use('Hash') | 6 | const Hash = use('Hash'); |
8 | 7 | ||
9 | class User extends Model { | 8 | class User extends Model { |
10 | static boot () { | 9 | static boot() { |
11 | super.boot() | 10 | super.boot(); |
12 | 11 | ||
13 | /** | 12 | /** |
14 | * A hook to hash the user password before saving | 13 | * A hook to hash the user password before saving |
@@ -16,9 +15,10 @@ class User extends Model { | |||
16 | */ | 15 | */ |
17 | this.addHook('beforeSave', async (userInstance) => { | 16 | this.addHook('beforeSave', async (userInstance) => { |
18 | if (userInstance.dirty.password) { | 17 | if (userInstance.dirty.password) { |
19 | userInstance.password = await Hash.make(userInstance.password) | 18 | // eslint-disable-next-line no-param-reassign |
19 | userInstance.password = await Hash.make(userInstance.password); | ||
20 | } | 20 | } |
21 | }) | 21 | }); |
22 | } | 22 | } |
23 | 23 | ||
24 | /** | 24 | /** |
@@ -31,17 +31,17 @@ class User extends Model { | |||
31 | * | 31 | * |
32 | * @return {Object} | 32 | * @return {Object} |
33 | */ | 33 | */ |
34 | tokens () { | 34 | tokens() { |
35 | return this.hasMany('App/Models/Token') | 35 | return this.hasMany('App/Models/Token'); |
36 | } | 36 | } |
37 | 37 | ||
38 | services () { | 38 | services() { |
39 | return this.hasMany('App/Models/Service', 'id', 'userId') | 39 | return this.hasMany('App/Models/Service', 'id', 'userId'); |
40 | } | 40 | } |
41 | 41 | ||
42 | workspaces () { | 42 | workspaces() { |
43 | return this.hasMany('App/Models/Workspace', 'id', 'userId') | 43 | return this.hasMany('App/Models/Workspace', 'id', 'userId'); |
44 | } | 44 | } |
45 | } | 45 | } |
46 | 46 | ||
47 | module.exports = User | 47 | module.exports = User; |