leave and admin update password
This commit is contained in:
parent
6dd45ecd93
commit
267d34d008
Binary file not shown.
@ -12,7 +12,7 @@ const leaveRecordSchema = new mongoose.Schema({
|
|||||||
},
|
},
|
||||||
location: {
|
location: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
// required: true,
|
||||||
},
|
},
|
||||||
reason: {
|
reason: {
|
||||||
type: String,
|
type: String,
|
||||||
@ -21,7 +21,7 @@ const leaveRecordSchema = new mongoose.Schema({
|
|||||||
leaveType: {
|
leaveType: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
enum: ["Sick Leave", "Casual Leave"],
|
enum: ["Sick Leave", "Privilege Leave","Personal Leave"],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -932,7 +932,7 @@ export const getUserOrderForAdmin = async (req, res) => {
|
|||||||
};
|
};
|
||||||
// 8.update User password
|
// 8.update User password
|
||||||
export const updatePassword = catchAsyncErrors(async (req, res, next) => {
|
export const updatePassword = catchAsyncErrors(async (req, res, next) => {
|
||||||
const user = await User.findById(req.user.id).select("+password");
|
const user = await User.findById(req.user._id).select("+password");
|
||||||
|
|
||||||
const isPasswordMatched = await user.comparePassword(req.body.oldPassword);
|
const isPasswordMatched = await user.comparePassword(req.body.oldPassword);
|
||||||
|
|
||||||
|
@ -11,11 +11,29 @@ const userSchema = new mongoose.Schema(
|
|||||||
uniqueId: {
|
uniqueId: {
|
||||||
type: String,
|
type: String,
|
||||||
unique: true,
|
unique: true,
|
||||||
required: true,
|
validate: {
|
||||||
|
validator: function (value) {
|
||||||
|
// Only require uniqueId if the role is not "admin"
|
||||||
|
if (this.role !== "admin" && !value) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
message: "Unique ID is required for users",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
SBU: {
|
SBU: {
|
||||||
type: String,
|
type: String,
|
||||||
required: [true, "Please Enter Your SBU"],
|
validate: {
|
||||||
|
validator: function (value) {
|
||||||
|
// Only require SBU if the role is not "admin"
|
||||||
|
if (this.role !== "admin" && !value) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
message: "SBU is required for users",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
name: {
|
name: {
|
||||||
type: String,
|
type: String,
|
||||||
|
Loading…
Reference in New Issue
Block a user