fix(big fix upgrade): upgrade multiple areas of the core functionalities
This commit is contained in:
@@ -5,6 +5,26 @@ export class User extends plugins.smartdata.SmartDataDbDoc<
|
||||
User,
|
||||
plugins.servezoneInterfaces.data.IUser
|
||||
> {
|
||||
/**
|
||||
* creates a machine user
|
||||
*/
|
||||
public static async createMachineUser(userNameArg: string, roleArg: 'api' | 'cluster') {
|
||||
const user = new User();
|
||||
user.id = await User.getNewId();
|
||||
user.data = {
|
||||
type: 'machine',
|
||||
username: userNameArg,
|
||||
tokens: [{
|
||||
token: 'machineUser',
|
||||
expiresAt: Date.now() + 3600 * 1000 * 24 * 365,
|
||||
assignedRoles: ['admin'],
|
||||
}],
|
||||
role: 'api',
|
||||
};
|
||||
await user.save();
|
||||
return user;
|
||||
}
|
||||
|
||||
public static async findUserByUsernameAndPassword(usernameArg: string, passwordArg: string) {
|
||||
return await User.getInstance({
|
||||
data: {
|
||||
@@ -14,6 +34,13 @@ export class User extends plugins.smartdata.SmartDataDbDoc<
|
||||
});
|
||||
}
|
||||
|
||||
constructor(optionsArg?: plugins.servezoneInterfaces.data.IUser) {
|
||||
super();
|
||||
if (optionsArg) {
|
||||
Object.assign(this, optionsArg);
|
||||
}
|
||||
}
|
||||
|
||||
// INSTANCE
|
||||
@plugins.smartdata.unI()
|
||||
public id: string;
|
||||
|
||||
Reference in New Issue
Block a user