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
8 changes: 4 additions & 4 deletions apps/core-api/src/controllers/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
verifyOtpService,
resetPasswordService,
verifySignupOtpService,

} from "../services/auth.service.js";
import type { HttpError } from "../modules/auth/http-error.js";
// import { log } from "winston";
Expand Down Expand Up @@ -120,7 +120,7 @@ export const refreshTokenController = async (
data: {
accessToken: result.accessToken,
user: result.user,

},
});
} catch (error) {
Expand Down Expand Up @@ -209,9 +209,9 @@ export const forgotPasswordController = async (
res.status(200).json({
success: true,
message: "If account exists, OTP sent",

});

} catch (error) {
next(error);
}
Expand Down
156 changes: 92 additions & 64 deletions apps/core-api/src/controllers/profile.controller.ts
Original file line number Diff line number Diff line change
@@ -1,65 +1,93 @@
import type { Response, NextFunction } from "express";

import {
getMyProfileService,
updateProfileService
} from "../services/profile.service.js";
import type { AuthRequest } from "../middlewares/auth.middleware.js";


export const getMyProfileController = async (
req: AuthRequest,
res: Response,
next: NextFunction
) => {
try {

if (!req.user) {
return res.status(401).json({
success: false,
message: "Unauthorized",
});
}

const userId = req.user.userId;

const profile = await getMyProfileService(userId);

res.status(200).json({
success: true,
data: profile
});

} catch (error) {
next(error);
}
};


export const updateProfileController = async (
req: AuthRequest,
res: Response,
next: NextFunction
) => {
try {

if (!req.user) {
return res.status(401).json({
success: false,
message: "Unauthorized",
});
}

const userId = req.user.userId;

const profile = await updateProfileService(userId, req.body);

res.status(200).json({
success: true,
data: profile
});

} catch (error) {
next(error);
}
};

import {
getMyProfileService,
updateProfileService,
getPublicInfluencerProfileService
} from "../services/profile.service.js";
import type { AuthRequest } from "../middlewares/auth.middleware.js";


export const getMyProfileController = async (
req: AuthRequest,
res: Response,
next: NextFunction
) => {
try {

if (!req.user) {
return res.status(401).json({
success: false,
message: "Unauthorized",
});
}

const userId = req.user.userId;

const profile = await getMyProfileService(userId);

res.status(200).json({
success: true,
data: profile
});

} catch (error) {
next(error);
}
};


export const updateProfileController = async (
req: AuthRequest,
res: Response,
next: NextFunction
) => {
try {

if (!req.user) {
return res.status(401).json({
success: false,
message: "Unauthorized",
});
}

const userId = req.user.userId;

const profile = await updateProfileService(userId, req.body);

res.status(200).json({
success: true,
data: profile
});

} catch (error) {
next(error);
}
};

export const getPublicInfluencerProfileController = async (
req: AuthRequest,
res: Response,
next: NextFunction
) => {
try {
const influencerId = req.params.id as string;

if (!influencerId) {
return res.status(400).json({
success: false,
message: "Influencer ID is required",
});
}

const data = await getPublicInfluencerProfileService(influencerId);

res.status(200).json({
success: true,
data
});

} catch (error) {
next(error);
}
};
4 changes: 2 additions & 2 deletions apps/core-api/src/modules/auth/auth.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import jwt from "jsonwebtoken";
import type { AdminLevel, UserRole } from "../../models/user.model.js";


const ACCESS_SECRET = process.env.JWT_ACCESS_SECRET!;
const REFRESH_SECRET = process.env.JWT_REFRESH_SECRET!;
const ACCESS_SECRET = process.env.ACCESS_SECRET!;
const REFRESH_SECRET = process.env.REFRESH_SECRET!;

export interface JwtPayload {
userId: string;
Expand Down
Loading
Loading