server: Validate tokens

This commit is contained in:
Elias Projahn 2020-05-11 18:12:58 +02:00
parent e897465fd7
commit 98e4d2cf83

View file

@ -166,7 +166,10 @@ class AuthorizationController extends Controller {
if (authHeaderParts.length == 2 && authHeaderParts[0] == 'Bearer') { if (authHeaderParts.length == 2 && authHeaderParts[0] == 'Bearer') {
final jwt = JWT.parse(authHeaderParts[1]); final jwt = JWT.parse(authHeaderParts[1]);
if (jwt.verify(_signer)) { /// The JWTValidator will automatically use the current time. An empty
/// result will mean that the token is valid and its signature was
/// verified.
if (JWTValidator().validate(jwt, signer: _signer).isEmpty) {
final user = await db.getUser(jwt.claims['user']); final user = await db.getUser(jwt.claims['user']);
if (user != null) { if (user != null) {
request.mayUpload = user.mayUpload; request.mayUpload = user.mayUpload;