fix(user): make email optional when creating and updating
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import axios from "axios";
|
||||
import { HrmsEmployee, Paging, User, UserRefreshToken, UserRole } from "entity";
|
||||
import { HrmsEmployee, Paging, User, UserRefreshToken, UserRole, UserToRoom } from "entity";
|
||||
import exceljs from "exceljs";
|
||||
import { NextFunction, Response } from "express";
|
||||
import { Request } from "express-jwt";
|
||||
@ -15,6 +15,7 @@ import fileUpload from "express-fileupload";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import config from "../../config/stag.json";
|
||||
import { IsNull } from "typeorm";
|
||||
|
||||
const log: Logger<ILogObj> = new Logger({
|
||||
name: "[UserController]",
|
||||
type: "pretty",
|
||||
@ -89,13 +90,13 @@ export class UserController {
|
||||
|
||||
const res_count = userRepository
|
||||
.createQueryBuilder("User")
|
||||
.leftJoin("User.roles", "roles")
|
||||
.leftJoin("User.roles", "roles")
|
||||
.where(whereAttr, whereVal);
|
||||
|
||||
const subquery = userRepository
|
||||
.createQueryBuilder("User")
|
||||
.select("User.id", "id")
|
||||
.leftJoin("User.roles", "roles")
|
||||
.leftJoin("User.roles", "roles")
|
||||
.where(whereAttr, whereVal)
|
||||
.orderBy("User." + param.order_field, param.order_direction)
|
||||
.offset(offset)
|
||||
@ -488,7 +489,7 @@ export class UserController {
|
||||
|
||||
try {
|
||||
const schema = Joi.object().keys({
|
||||
email: Joi.string().email().max(64).optional().label("Email"),
|
||||
email: Joi.string().email().max(64).allow("", null).optional().label("Email"),
|
||||
username: Joi.string().max(64).required().label("Username"),
|
||||
password: Joi.string().pattern(new RegExp("^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{8,}$")).min(8).required().label("Password"),
|
||||
retype_password: Joi.ref("password"),
|
||||
@ -895,7 +896,7 @@ export class UserController {
|
||||
try {
|
||||
const schema = Joi.object().keys({
|
||||
id: Joi.string().uuid().required().label("ID"),
|
||||
email: Joi.string().email().max(64).required().label("Email"),
|
||||
email: Joi.string().email().max(64).allow("", null).optional().label("Email"),
|
||||
username: Joi.string().max(64).required().label("Username"),
|
||||
password: Joi.string().allow("").optional().label("Password"),
|
||||
name: Joi.string().max(64).required().label("Name"),
|
||||
@ -920,7 +921,7 @@ export class UserController {
|
||||
// await UserController.deleteFile(oldFilePath);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
data.profile_picture = param.profile_picture || data.profile_picture;
|
||||
data.name = param.name;
|
||||
data.username = param.username;
|
||||
@ -1127,6 +1128,14 @@ export class UserController {
|
||||
where: { id: param.id },
|
||||
});
|
||||
|
||||
// get all the rooms from the usertoroom
|
||||
// const repo = OrmHelper.DB.getRepository(UserToRoom);
|
||||
|
||||
// const rooms = await repo.createQueryBuilder('utr')
|
||||
// .select('utr.id_room')
|
||||
// .where('utr.user_id = :id', { id: param.id })
|
||||
// .getMany();
|
||||
|
||||
if (detail != null) {
|
||||
const data = {
|
||||
...detail,
|
||||
|
||||
@ -22,7 +22,7 @@ const doc = {
|
||||
},
|
||||
user: {
|
||||
$employee_id: "EMP001",
|
||||
$email: "admin@gmail.com",
|
||||
email: "admin@gmail.com",
|
||||
$username: "admin",
|
||||
$password: "12345aA!",
|
||||
$retype_password: "12345aA!",
|
||||
@ -35,7 +35,7 @@ const doc = {
|
||||
$status: "Y"
|
||||
},
|
||||
user_profile: {
|
||||
$email: "admin@gmail.com",
|
||||
email: "admin@gmail.com",
|
||||
$username: "admin",
|
||||
$name: "Administrator"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user