Skip to content

Commit

Permalink
userInfo and bearer
Browse files Browse the repository at this point in the history
  • Loading branch information
Tuyisenge2 committed Mar 29, 2024
1 parent 7649e25 commit d9685a6
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/controllers/user.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,16 @@ const isPasswordValid = await bcrypt.compare(password, user.password);

const infoToken=async(req:Request,res:Response)=>{
try{
let token = req.headers.authorization;

if (!token) {
return res.status(400).json({
message:"please login in "
}); ;

}
let token;
if(req.headers.authorization){
token=req.headers.authorization.split(' ')[1];
}

if(!token){
return res.status(401).json({
message:"you must login please"
});
}

const decoded = Jwt.verify(token, "eonfeinefiueriu") as any;

Expand Down

0 comments on commit d9685a6

Please sign in to comment.