First part of the action comment refactoring
ref #39 Why did i volunteer for this? It's just a glorified sleeping aid 😴
This commit is contained in:
@@ -7,10 +7,14 @@ import { UserGroupNotFoundError } from '../../errors/UserGroupErrors';
|
||||
import { User } from '../entities/User';
|
||||
import { UserGroup } from '../entities/UserGroup';
|
||||
|
||||
/**
|
||||
* This class is used to update a User entity (via put request).
|
||||
*/
|
||||
export class UpdateUser {
|
||||
|
||||
/**
|
||||
* The updated users's id.
|
||||
* The updated user's id.
|
||||
* This shouldn't have changed but it is here in case anyone ever wants to enable id changes (whyever they would want to).
|
||||
*/
|
||||
@IsInt()
|
||||
id: number;
|
||||
@@ -23,7 +27,6 @@ export class UpdateUser {
|
||||
|
||||
/**
|
||||
* The updated user's middle name.
|
||||
* Optinal.
|
||||
*/
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
@@ -54,14 +57,16 @@ export class UpdateUser {
|
||||
|
||||
/**
|
||||
* The updated user's phone number.
|
||||
* Optional
|
||||
* This will be validated against the configured country phone numer syntax (default: international).
|
||||
*/
|
||||
@IsPhoneNumber(config.phone_validation_countrycode)
|
||||
@IsOptional()
|
||||
phone?: string;
|
||||
|
||||
/**
|
||||
* The new updated's password. Only provide if you want it updated.
|
||||
* The new updated's password.
|
||||
* Only provide it if you want it updated.
|
||||
* Changeing the password will invalidate all of the user's jwts.
|
||||
* This will of course not be saved in plaintext :)
|
||||
*/
|
||||
@IsString()
|
||||
@@ -75,15 +80,14 @@ export class UpdateUser {
|
||||
enabled: boolean = true;
|
||||
|
||||
/**
|
||||
* The new user's groups' id(s).
|
||||
* You can provide either one groupId or an array of groupIDs.
|
||||
* Optional.
|
||||
* The updated user's groups.
|
||||
* This just has to contain the group's id - everything else won't be changed.
|
||||
*/
|
||||
@IsOptional()
|
||||
groups?: UserGroup[]
|
||||
|
||||
/**
|
||||
* Creates a User entity from this.
|
||||
* Updates a provided User entity based on this.
|
||||
*/
|
||||
public async updateUser(user: User): Promise<User> {
|
||||
user.email = this.email;
|
||||
@@ -107,6 +111,9 @@ export class UpdateUser {
|
||||
return user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the updated user's groups based on their ids.
|
||||
*/
|
||||
public async getGroups() {
|
||||
if (!this.groups) { return null; }
|
||||
let groups = new Array<UserGroup>();
|
||||
|
||||
Reference in New Issue
Block a user