Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,7 @@ base url: `http://localhost:3000`
- Remove member from a project: `DELETE /api/organization/:organizationId/team/:teamId/project/:projectId/removeMember`
- Get all projects: `GET /api/organization/:organizationId/team/:teamId/project/all`
- Get a specific project: `GET /api/organization/:organizationId/team/:teamId/project/:projectId`

### Task

- Create a new task: `POST /api/organization/:organizationId/team/:teamId/project/:projectId/task/create`
8 changes: 4 additions & 4 deletions src/controllers/auth.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ export const signin = async (req, res, next) => {
try {
const { email, password } = req.body;

const { error } = signinValidation();
const { error } = signinValidation(req.body);
if (error) {
return res.status(400).json({ error: error.details[0].message });
}
Expand Down Expand Up @@ -281,7 +281,7 @@ export const signin = async (req, res, next) => {
*/
export const forgotPassword = async (req, res, next) => {
try {
const { error } = forgotPasswordValidation();
const { error } = forgotPasswordValidation(req.body);
if (error) {
return res.status(400).json({ message: error.details[0].message });
}
Expand Down Expand Up @@ -335,7 +335,7 @@ export const forgotPassword = async (req, res, next) => {
*/
export const resetPassword = async (req, res, next) => {
try {
const { error } = resetPasswordValidation();
const { error } = resetPasswordValidation(req.body);
if (error) {
return res.status(400).json({ message: error.details[0].message });
}
Expand Down Expand Up @@ -446,7 +446,7 @@ export const forgotPasswordWithoutEmail = async (req, res, next) => {
*/
export const resetPasswordWithoutEmail = async (req, res, next) => {
try {
const { error } = resetPasswordValidation();
const { error } = resetPasswordValidation(req.body);
if (error) {
return res.status(400).json({ message: error.details[0].message });
}
Expand Down
39 changes: 18 additions & 21 deletions src/controllers/organization.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ export const createOrganization = async (req, res, next) => {
});
}

// Determine if this is an admin creation (for status and verification)
const isAdminCreation = req.user.role === 'ADMIN';

// generate OTP
const verificationOTP = generateOTP();
const hashedOTP = await hashOTP(verificationOTP);
Expand All @@ -72,8 +69,8 @@ export const createOrganization = async (req, res, next) => {
address,
contactEmail,
contactPhone,
status: isAdminCreation ? 'APPROVED' : 'PENDING',
isVerified: isAdminCreation,
status: 'APPROVED',
isVerified: true,
createdBy: req.user.id,
emailVerificationOTP: hashedOTP,
emailVerificationExpires: otpExpiry,
Expand Down Expand Up @@ -102,22 +99,22 @@ export const createOrganization = async (req, res, next) => {
});

// Handle verification for non-admin creation
if (!isAdminCreation && contactEmail) {
try {
// Send verification email
await sendEmail({
to: contactEmail,
subject: 'Verify Your Organization Email',
text: `Organization name: ${result.org.name}\nYour verification code is: ${verificationOTP}. will expire in 10 min`,
});
} catch (error) {
return res.status(500).json({
success: false,
error,
message: 'Failed to send verification email. Please try again later.',
});
}
}
// if (!isAdminCreation && contactEmail) {
// try {
// // Send verification email
// await sendEmail({
// to: contactEmail,
// subject: 'Verify Your Organization Email',
// text: `Organization name: ${result.org.name}\nYour verification code is: ${verificationOTP}. will expire in 10 min`,
// });
// } catch (error) {
// return res.status(500).json({
// success: false,
// error,
// message: 'Failed to send verification email. Please try again later.',
// });
// }
// }

return res.status(201).json({
success: true,
Expand Down
5 changes: 1 addition & 4 deletions src/controllers/project.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ const checkOrganization = async (organizationId) => {
};

/**
* Helper function to check if department exists and is not deleted
* @param {string} departmentId - The department ID to check
* @returns {Promise<Object>} - Contains success flag, error message, and department data
* Helper function to check if team exists and is not deleted
*/
const checkTeam = async (
teamId,
Expand Down Expand Up @@ -105,7 +103,6 @@ const checkTeam = async (
* Helper function to check if team exists and is not deleted
* @param {string} teamId - The team ID to check
* @param {string} organizationId - The organization ID the team belongs to
* @param {string} [departmentId] - Optional department ID the team belongs to
* @param {Object} [options] - Additional options for the query
* @returns {Promise<Object>} - Contains success flag, error message, and team data
*/
Expand Down
Loading