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 | // curl -i -H "Authorization:[token]" localhost:31459/api/v1/user/history | ||||||
|  |  | ||||||
| const tokenToUser = (req, res, next) => { | const tokenToUser = (req, res, next) => { | ||||||
|    const rawToken = req.headers.authorization; |   const rawToken = req.headers.authorization; | ||||||
|    if (rawToken) { |   if (rawToken) { | ||||||
|       try { |     try { | ||||||
|          const token = Token.fromString(rawToken, secret); |       const token = Token.fromString(rawToken, secret); | ||||||
|          req.loggedInUser = token.user; |       req.loggedInUser = token.user; | ||||||
|       } catch (error) { |     } catch (error) { | ||||||
|          req.loggedInUser = undefined; |       req.loggedInUser = undefined; | ||||||
|       } |     } | ||||||
|    } |   } | ||||||
|    next(); |   next(); | ||||||
| }; | }; | ||||||
|  |  | ||||||
| module.exports = tokenToUser; | module.exports = tokenToUser; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user