Updated formatting
This commit is contained in:
		
							
								
								
									
										
											BIN
										
									
								
								seasoned_api/src/webserver/middleware/.tokenToUser.js.swp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								seasoned_api/src/webserver/middleware/.tokenToUser.js.swp
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| @@ -8,16 +8,16 @@ const Token = require('src/user/token'); | ||||
| // curl -i -H "Authorization:[token]" localhost:31459/api/v1/user/history | ||||
|  | ||||
| const tokenToUser = (req, res, next) => { | ||||
|    const rawToken = req.headers.authorization; | ||||
|    if (rawToken) { | ||||
|       try { | ||||
|          const token = Token.fromString(rawToken, secret); | ||||
|          req.loggedInUser = token.user; | ||||
|       } catch (error) { | ||||
|          req.loggedInUser = undefined; | ||||
|       } | ||||
|    } | ||||
|    next(); | ||||
|   const rawToken = req.headers.authorization; | ||||
|   if (rawToken) { | ||||
|     try { | ||||
|       const token = Token.fromString(rawToken, secret); | ||||
|       req.loggedInUser = token.user; | ||||
|     } catch (error) { | ||||
|       req.loggedInUser = undefined; | ||||
|     } | ||||
|   } | ||||
|   next(); | ||||
| }; | ||||
|  | ||||
| module.exports = tokenToUser; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user