Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui) : fix landing page responsive issue in Xl #86

Merged
merged 16 commits into from
Feb 23, 2025
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
7 changes: 6 additions & 1 deletion backend/src/constants/response-message.constant.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
export const HttpResponse = {
SERVER_ERROR: "Internel server error",
SERVER_ERROR: "Internal server error",
USER_EXIST: "User already exist",
PAGE_NOT_FOUND: "Route not found",
USER_NOT_FOUND: "User not found",
PASSWORD_INCORRECT: "Incorrect password, try again",
NO_TOKEN: "Token not provided",
OTP_INCORRECT: "Incorrect otp, try again",
OTP_NOT_FOUND: "Otp not found",
INVALID_CREDENTIALS: "Invalid credentials",
USER_CREATION_FAILED: "User creation failed",
USER_CREATION_SUCCESS: "User created successfully",
};
73 changes: 45 additions & 28 deletions backend/src/controllers/implementation/auth.controller.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,57 @@
import { Request, Response, NextFunction } from "express";
import { IAuthService } from "../../services/interface/IAuthService";
import { IAuthController } from "../interface/IAuthController";
import { HttpStatus } from "@/constants/status.constant";

export class AuthController implements IAuthController {
constructor(private _authService: IAuthService) {}

async signup(req: Request, res: Response, next: NextFunction): Promise<void> {
try {
const user = await this._authService.signup(req.body);

export class AuthController implements IAuthController{
constructor(private _authService: IAuthService){}

async signup(req: Request, res: Response, next: NextFunction): Promise<void> {
try{
const user = await this._authService.signup(req.body)

res.status(200).json({
email: user
})
}catch(err){
next(err)
}
res.status(200).json({
email: user,
});
} catch (err) {
next(err);
}
}

async signin(req: Request, res: Response, next: NextFunction): Promise<void> {
try{
const { email, password } = req.body;
async signin(req: Request, res: Response, next: NextFunction): Promise<void> {
try {
const { email, password } = req.body;

const tokens = await this._authService.signin(email, password);
const tokens = await this._authService.signin(email, password);

res.cookie("refreshToken", tokens.refreshToken, {
httpOnly: true,
secure: false,
maxAge: 7 * 24 * 60 * 60 * 1000,
sameSite: "strict"
});
res.cookie("refreshToken", tokens.refreshToken, {
httpOnly: true,
secure: false,
maxAge: 7 * 24 * 60 * 60 * 1000,
sameSite: "strict",
});

res.status(200).json({accessToken: tokens.accessToken});
}catch(err){
next(err)
}
res.status(200).json({ accessToken: tokens.accessToken });
} catch (err) {
next(err);
}
}
async verifyOtp(
req: Request,
res: Response,
next: NextFunction
): Promise<void> {
try {
const { otp, email } = req.body;

const verificationResponse = await this._authService.verifyOtp(
otp,
email
);

res.status(HttpStatus.CREATED).json(verificationResponse);
} catch (err) {
next(err);
}
}
}
}
109 changes: 54 additions & 55 deletions backend/src/models/implementation/user.model.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {model, Schema, Document} from "mongoose";
import {IUser} from "shared/types";
import { model, Schema, Document } from "mongoose";
import { IUser } from "shared/types";

// interface IUser {
// _id: string;
Expand All @@ -21,61 +21,60 @@ import {IUser} from "shared/types";
export interface IUserModel extends Document, Omit<IUser, "_id"> {}

const userSchema = new Schema<IUserModel>(
{
username: {
type: String,
required: true,
unique: true
},
name: {
type: String,
},
email: {
type: String,
required: true,
unique: true
},
password: {
type: String,
},
status: {
type: String,
enum: ["active", "blocked"],
default: "active",
},
role: {
type: String,
enum: ["user", "moderator"],
default: "user",
},
bio: {
type: String,
},
profile_picture: {
type: String,
},
social_links: [
{
type: {
type: String,
},
url: {
type: String,
},
},
],
resume: {
type: String,
{
username: {
type: String,
required: true,
unique: true,
},
name: {
type: String,
},
email: {
type: String,
required: true,
unique: true,
},
password: {
type: String,
},
status: {
type: String,
enum: ["active", "blocked"],
default: "active",
},
role: {
type: String,
enum: ["user", "moderator"],
default: "user",
},
bio: {
type: String,
},
profile_picture: {
type: String,
},
social_links: [
{
type: {
type: String,
},
date_of_birth: {
type: Date,
url: {
type: String,
},
},
],
resume: {
type: String,
},
{
timestamps: {createdAt: "created_at", updatedAt: "updated_at"},
}
date_of_birth: {
type: Date,
},
},
{
timestamps: { createdAt: "created_at", updatedAt: "updated_at" },
}
);


const User = model<IUserModel>('User', userSchema);
export default User
const User = model<IUserModel>("User", userSchema);
export default User;
8 changes: 4 additions & 4 deletions backend/src/routers/auth.router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { AuthController } from "../controllers/implementation/auth.controller";
import { AuthService } from "../services/implementation/auth.service";
import { UserRepository } from "../repositories/implementation/user.repository";


const authRouter = Router();

const userRepository = new UserRepository();
const authService = new AuthService(userRepository);
const authController = new AuthController(authService);

authRouter.post('/register',authController.signup.bind(authController));
authRouter.post('/login',authController.signin.bind(authController));
authRouter.post("/register", authController.signup.bind(authController));
authRouter.post("/login", authController.signin.bind(authController));
authRouter.post("/otp", authController.verifyOtp.bind(authController));

export default authRouter;
export default authRouter;
Loading
Loading