user role + module alias
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
import './paths';
|
||||
import Server from './framework/express/server';
|
||||
import ip from 'ip';
|
||||
import UserModel from './framework/mongo/user';
|
||||
|
@ -2,6 +2,7 @@ import {
|
||||
UserCtor,
|
||||
UserInfo,
|
||||
UserInfoWithPassword,
|
||||
UserRoles,
|
||||
UserWithPasswordCtor,
|
||||
} from '@core';
|
||||
import { generateHash } from '../functions/password';
|
||||
@ -9,17 +10,20 @@ import { Entity } from './entity';
|
||||
|
||||
export class User extends Entity implements UserInfo {
|
||||
username: string;
|
||||
role: keyof typeof UserRoles;
|
||||
|
||||
constructor(raw: UserCtor) {
|
||||
super(raw);
|
||||
|
||||
this.username = raw.username ? raw.username : '';
|
||||
this.username = raw.username || '';
|
||||
this.role = raw.role || UserRoles.USER;
|
||||
}
|
||||
|
||||
Info(): UserInfo {
|
||||
return {
|
||||
uuid: this.uuid,
|
||||
username: this.username,
|
||||
role: this.role,
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -37,6 +41,7 @@ export class UserWithPassword extends User implements UserInfoWithPassword {
|
||||
return {
|
||||
uuid: this.uuid,
|
||||
username: this.username,
|
||||
role: this.role,
|
||||
password: this.password,
|
||||
};
|
||||
}
|
||||
|
5
api/src/paths.ts
Normal file
5
api/src/paths.ts
Normal file
@ -0,0 +1,5 @@
|
||||
import { addAliases } from 'module-alias';
|
||||
|
||||
addAliases({
|
||||
'@core': `${__dirname}/../../core/src`,
|
||||
});
|
Reference in New Issue
Block a user