Commit 4bfb7be6 authored by Phạm Quang Bảo's avatar Phạm Quang Bảo

fix: rename middleware auth

parent e657aea5
import { login } from "#middlewares/authentication"; import { authenticate } from "#middlewares/authentication";
import { AuthService } from "#services/authService"; import { AuthService } from "#services/authService";
import { Application } from "express"; import { Application } from "express";
import { Resource } from "express-automatic-routes"; import { Resource } from "express-automatic-routes";
...@@ -24,7 +24,7 @@ export default (_express: Application) => { ...@@ -24,7 +24,7 @@ export default (_express: Application) => {
* $ref: "#/components/schemas/logoutResponse" * $ref: "#/components/schemas/logoutResponse"
*/ */
post: { post: {
middleware: [login], middleware: [authenticate],
handler: async (req, res) => { handler: async (req, res) => {
try { try {
......
import { login } from "#middlewares/authentication"; import { authenticate } from "#middlewares/authentication";
import { AuthService } from "#services/authService"; import { AuthService } from "#services/authService";
import { Application } from "express"; import { Application } from "express";
import { Resource } from "express-automatic-routes"; import { Resource } from "express-automatic-routes";
...@@ -24,7 +24,7 @@ export default (_express: Application) => { ...@@ -24,7 +24,7 @@ export default (_express: Application) => {
* $ref: "#/components/schemas/Profile" * $ref: "#/components/schemas/Profile"
*/ */
get: { get: {
middleware: [login], middleware: [authenticate],
handler: async (req, res) => { handler: async (req, res) => {
try { try {
......
import { login } from "#middlewares/authentication"; import { authenticate } from "#middlewares/authentication";
import { AuthService } from "#services/authService.js"; import { AuthService } from "#services/authService.js";
import { MailService } from "#services/mailService.js"; import { MailService } from "#services/mailService.js";
import { Application } from "express"; import { Application } from "express";
...@@ -28,7 +28,7 @@ export default (_express: Application) => { ...@@ -28,7 +28,7 @@ export default (_express: Application) => {
* $ref: "#/components/schemas/sendOtpResponse" * $ref: "#/components/schemas/sendOtpResponse"
*/ */
post: { post: {
middleware: [login], middleware: [authenticate],
handler: async (req, res) => { handler: async (req, res) => {
try { try {
......
import { login } from "#middlewares/authentication"; import { authenticate } from "#middlewares/authentication";
import { AuthService } from "#services/authService.js"; import { AuthService } from "#services/authService.js";
import { Application } from "express"; import { Application } from "express";
import { Resource } from "express-automatic-routes"; import { Resource } from "express-automatic-routes";
...@@ -32,7 +32,7 @@ export default (_express: Application) => { ...@@ -32,7 +32,7 @@ export default (_express: Application) => {
* $ref: "#/components/schemas/verifyOtpResponse" * $ref: "#/components/schemas/verifyOtpResponse"
*/ */
post: { post: {
middleware: [login], middleware: [authenticate],
handler: async (req, res) => { handler: async (req, res) => {
try { try {
......
...@@ -4,7 +4,7 @@ import { Response, NextFunction } from 'express'; ...@@ -4,7 +4,7 @@ import { Response, NextFunction } from 'express';
//demo //demo
const JWT_SECRET = process.env.JWT_SECRET || ''; const JWT_SECRET = process.env.JWT_SECRET || '';
export const login = (req: any, res: Response, next: NextFunction) => { export const authenticate = (req: any, res: Response, next: NextFunction) => {
const authHeader = req.headers.authorization; const authHeader = req.headers.authorization;
if (!authHeader || !authHeader.startsWith('Bearer ')) { if (!authHeader || !authHeader.startsWith('Bearer ')) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment