fix(user): make email optional when creating and updating
This commit is contained in:
@ -1,5 +1,5 @@
|
|||||||
import axios from "axios";
|
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 exceljs from "exceljs";
|
||||||
import { NextFunction, Response } from "express";
|
import { NextFunction, Response } from "express";
|
||||||
import { Request } from "express-jwt";
|
import { Request } from "express-jwt";
|
||||||
@ -15,6 +15,7 @@ import fileUpload from "express-fileupload";
|
|||||||
import { v4 as uuidv4 } from "uuid";
|
import { v4 as uuidv4 } from "uuid";
|
||||||
import config from "../../config/stag.json";
|
import config from "../../config/stag.json";
|
||||||
import { IsNull } from "typeorm";
|
import { IsNull } from "typeorm";
|
||||||
|
|
||||||
const log: Logger<ILogObj> = new Logger({
|
const log: Logger<ILogObj> = new Logger({
|
||||||
name: "[UserController]",
|
name: "[UserController]",
|
||||||
type: "pretty",
|
type: "pretty",
|
||||||
@ -488,7 +489,7 @@ export class UserController {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const schema = Joi.object().keys({
|
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"),
|
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"),
|
password: Joi.string().pattern(new RegExp("^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{8,}$")).min(8).required().label("Password"),
|
||||||
retype_password: Joi.ref("password"),
|
retype_password: Joi.ref("password"),
|
||||||
@ -895,7 +896,7 @@ export class UserController {
|
|||||||
try {
|
try {
|
||||||
const schema = Joi.object().keys({
|
const schema = Joi.object().keys({
|
||||||
id: Joi.string().uuid().required().label("ID"),
|
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"),
|
username: Joi.string().max(64).required().label("Username"),
|
||||||
password: Joi.string().allow("").optional().label("Password"),
|
password: Joi.string().allow("").optional().label("Password"),
|
||||||
name: Joi.string().max(64).required().label("Name"),
|
name: Joi.string().max(64).required().label("Name"),
|
||||||
@ -1127,6 +1128,14 @@ export class UserController {
|
|||||||
where: { id: param.id },
|
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) {
|
if (detail != null) {
|
||||||
const data = {
|
const data = {
|
||||||
...detail,
|
...detail,
|
||||||
|
|||||||
@ -22,7 +22,7 @@ const doc = {
|
|||||||
},
|
},
|
||||||
user: {
|
user: {
|
||||||
$employee_id: "EMP001",
|
$employee_id: "EMP001",
|
||||||
$email: "admin@gmail.com",
|
email: "admin@gmail.com",
|
||||||
$username: "admin",
|
$username: "admin",
|
||||||
$password: "12345aA!",
|
$password: "12345aA!",
|
||||||
$retype_password: "12345aA!",
|
$retype_password: "12345aA!",
|
||||||
@ -35,7 +35,7 @@ const doc = {
|
|||||||
$status: "Y"
|
$status: "Y"
|
||||||
},
|
},
|
||||||
user_profile: {
|
user_profile: {
|
||||||
$email: "admin@gmail.com",
|
email: "admin@gmail.com",
|
||||||
$username: "admin",
|
$username: "admin",
|
||||||
$name: "Administrator"
|
$name: "Administrator"
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user