aboutsummaryrefslogtreecommitdiffstats
path: root/app/Models/User.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/Models/User.js')
-rw-r--r--app/Models/User.js46
1 files changed, 0 insertions, 46 deletions
diff --git a/app/Models/User.js b/app/Models/User.js
deleted file mode 100644
index 4472017..0000000
--- a/app/Models/User.js
+++ /dev/null
@@ -1,46 +0,0 @@
1/** @type {typeof import('@adonisjs/lucid/src/Lucid/Model')} */
2const Model = use('Model');
3
4/** @type {import('@adonisjs/framework/src/Hash')} */
5const Hash = use('Hash');
6
7class User extends Model {
8 static boot() {
9 super.boot();
10
11 /**
12 * A hook to hash the user password before saving
13 * it to the database.
14 */
15 this.addHook('beforeSave', async (userInstance) => {
16 if (userInstance.dirty.password) {
17 // eslint-disable-next-line no-param-reassign
18 userInstance.password = await Hash.make(userInstance.password);
19 }
20 });
21 }
22
23 /**
24 * A relationship on tokens is required for auth to
25 * work. Since features like `refreshTokens` or
26 * `rememberToken` will be saved inside the
27 * tokens table.
28 *
29 * @method tokens
30 *
31 * @return {Object}
32 */
33 tokens() {
34 return this.hasMany('App/Models/Token');
35 }
36
37 services() {
38 return this.hasMany('App/Models/Service', 'id', 'userId');
39 }
40
41 workspaces() {
42 return this.hasMany('App/Models/Workspace', 'id', 'userId');
43 }
44}
45
46module.exports = User;