vapor / fluent

Vapor ORM (queries, models, and relations) for NoSQL and SQL databases
https://docs.vapor.codes/4.0/fluent/overview/
MIT License
1.32k stars 172 forks source link

Tokens don't conform to `Authenticatable` #671

Closed 0xTim closed 4 years ago

0xTim commented 4 years ago

In Vapor 4, Tokens don't currently conform to Authenticatable. An example of where this would be useful is when invalidating a token:

func logoutHandler(_ req: Request) throws -> EventLoopFuture<HTTPStatus> {
  let token = try req.auth.require(UserToken.self)
  return token.delete(on: req.db).transform(to: .ok)
}

Currently the only ways to achieve this are with extra DB calls, but the middleware has already done that lookup, so the token should be cached somewhere where it can be retrieved

tanner0101 commented 4 years ago

Fixed in #672