parent
d948fe2631
commit
3c37aafe1f
|
@ -1,5 +1,5 @@
|
|||
import * as argon2 from "argon2";
|
||||
import { IsBoolean, IsEmail, IsOptional, IsPhoneNumber, IsString } from 'class-validator';
|
||||
import { IsBoolean, IsEmail, IsOptional, IsPhoneNumber, IsString, IsUrl } from 'class-validator';
|
||||
import { getConnectionManager } from 'typeorm';
|
||||
import * as uuid from 'uuid';
|
||||
import { config } from '../../config';
|
||||
|
@ -78,7 +78,13 @@ export class CreateUser {
|
|||
@IsOptional()
|
||||
groups?: number[] | number
|
||||
|
||||
//TODO: ProfilePics
|
||||
/**
|
||||
* The user's profile pic (or rather a url pointing to it).
|
||||
*/
|
||||
@IsString()
|
||||
@IsUrl()
|
||||
@IsOptional()
|
||||
profilePic?: string;
|
||||
|
||||
/**
|
||||
* Converts this to a User entity.
|
||||
|
@ -100,7 +106,9 @@ export class CreateUser {
|
|||
newUser.password = await argon2.hash(this.password + newUser.uuid);
|
||||
newUser.groups = await this.getGroups();
|
||||
newUser.enabled = this.enabled;
|
||||
//TODO: ProfilePics
|
||||
|
||||
if (!this.profilePic) { newUser.profilePic = `https://dev.lauf-fuer-kaya.de/lfk-logo.png`; }
|
||||
else { newUser.profilePic = this.profilePic; }
|
||||
|
||||
return newUser;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as argon2 from "argon2";
|
||||
import { IsBoolean, IsEmail, IsInt, IsOptional, IsPhoneNumber, IsString } from 'class-validator';
|
||||
import { IsBoolean, IsEmail, IsInt, IsOptional, IsPhoneNumber, IsString, IsUrl } from 'class-validator';
|
||||
import { getConnectionManager } from 'typeorm';
|
||||
import { config } from '../../config';
|
||||
import { UsernameOrEmailNeededError } from '../../errors/AuthError';
|
||||
|
@ -87,7 +87,16 @@ export class UpdateUser {
|
|||
groups?: UserGroup[]
|
||||
|
||||
/**
|
||||
* Updates a provided User entity based on this.
|
||||
* The user's profile pic (or rather a url pointing to it).
|
||||
*/
|
||||
@IsString()
|
||||
@IsUrl()
|
||||
@IsOptional()
|
||||
profilePic?: string;
|
||||
|
||||
/**
|
||||
* Updates a user entity based on this.
|
||||
* @param user The user that shall be updated.
|
||||
*/
|
||||
public async updateUser(user: User): Promise<User> {
|
||||
user.email = this.email;
|
||||
|
@ -106,7 +115,9 @@ export class UpdateUser {
|
|||
user.lastname = this.lastname
|
||||
user.phone = this.phone;
|
||||
user.groups = await this.getGroups();
|
||||
//TODO: ProfilePics
|
||||
|
||||
if (!this.profilePic) { user.profilePic = `https://dev.lauf-fuer-kaya.de/lfk-logo.png`; }
|
||||
else { user.profilePic = this.profilePic; }
|
||||
|
||||
return user;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { IsBoolean, IsEmail, IsInt, IsNotEmpty, IsOptional, IsPhoneNumber, IsString, IsUUID } from "class-validator";
|
||||
import { IsBoolean, IsEmail, IsInt, IsNotEmpty, IsOptional, IsPhoneNumber, IsString, IsUrl, IsUUID } from "class-validator";
|
||||
import { ChildEntity, Column, JoinTable, ManyToMany, OneToMany } from "typeorm";
|
||||
import { config } from '../../config';
|
||||
import { ResponsePrincipal } from '../responses/ResponsePrincipal';
|
||||
|
@ -106,10 +106,10 @@ export class User extends Principal {
|
|||
* The user's profile picture.
|
||||
* We haven't decided yet if this will be a bas64 encoded image or just a link to the profile picture.
|
||||
*/
|
||||
@Column({ nullable: true, unique: false })
|
||||
@Column({ nullable: false, unique: false })
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
profilePic?: string;
|
||||
@IsUrl()
|
||||
profilePic: string;
|
||||
|
||||
/**
|
||||
* The last time the user requested a password reset.
|
||||
|
|
|
@ -57,11 +57,10 @@ export class ResponseUser extends ResponsePrincipal {
|
|||
enabled: boolean = true;
|
||||
|
||||
/**
|
||||
* The user's profile pic.
|
||||
* The user's profile pic (or rather a url pointing to it).
|
||||
*/
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
profilePic?: string;
|
||||
profilePic: string;
|
||||
|
||||
/**
|
||||
* The groups that the user is a part of.
|
||||
|
|
Loading…
Reference in New Issue