mirror of
https://github.com/johrpan/musicus_mobile.git
synced 2025-10-26 18:57:25 +01:00
server: Validate tokens
This commit is contained in:
parent
e897465fd7
commit
98e4d2cf83
1 changed files with 4 additions and 1 deletions
|
|
@ -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;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue