Explorar o código

Delete token if it has been successfully used

sbkwgh %!s(int64=8) %!d(string=hai) anos
pai
achega
de1feba110
Modificáronse 1 ficheiros con 4 adicións e 0 borrados
  1. 4 0
      routes/user.js

+ 4 - 0
routes/user.js

@@ -77,6 +77,10 @@ router.post('/', async (req, res) => {
 		userParams.hash = hash
 		user = await User.create(userParams)
 
+		if(req.body.token) {
+			await token.destroy()
+		}
+
 		req.session.loggedIn = true
 		req.session.username = user.username
 		res.json(user.toJSON())