-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #86 from TheByteFlow/frontend
fix(ui) : fix landing page responsive issue in Xl
- Loading branch information
Showing
9 changed files
with
1,796 additions
and
253 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
73
backend/src/controllers/implementation/auth.controller.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
); | ||
|
||
res.status(HttpStatus.CREATED).json(verificationResponse); | ||
} catch (err) { | ||
next(err); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.