UNPKG

758 BJavaScriptView Raw
1/**
2 * @copyright Copyright (c) 2019 Maxim Khorin <maksimovichu@gmail.com>
3 */
4'use strict';
5
6const Base = require('../base/Base');
7
8module.exports = class Identity extends Base {
9
10 getId () {
11 return this.get(this.PK);
12 }
13
14 getTitle () {
15 return this.getId();
16 }
17
18 getAssignments () {
19 // get user's assigned roles []
20 return this.module.get('rbac').getUserAssignments(this.getId());
21 }
22
23 getAuthKey () {
24 return this.get('authKey'); // key for 'remember me' cookie
25 }
26
27 setAuthKey () {
28 this.set('authKey', SecurityHelper.getRandomString(16));
29 }
30
31 checkAuthKey (key) {
32 return this.getAuthKey() === key;
33 }
34};
35
36const SecurityHelper = require('../helper/SecurityHelper');
\No newline at end of file