Skip to content

Commit

Permalink
Update PermissionService.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
johnthagen committed Oct 23, 2020
1 parent 93a96de commit 90c5f5a
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion Backend/Services/PermissionService.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.IdentityModel.Tokens.Jwt;
using BackendFramework.Interfaces;
using BackendFramework.Models;
Expand Down Expand Up @@ -102,8 +103,28 @@ public string GetUserId(HttpContext request)
{
var jsonToken = GetJwt(request);
var userId = ((JwtSecurityToken)jsonToken).Payload["UserId"].ToString();
if (userId == null)
{
throw new InvalidJwtTokenError();
}

return userId;
}

[Serializable]
public class InvalidJwtTokenError : Exception
{
public InvalidJwtTokenError()
{ }

public InvalidJwtTokenError(string message)
: base(message)
{ }

public InvalidJwtTokenError(string message, Exception innerException)
: base(message, innerException)
{ }
}
}
}

0 comments on commit 90c5f5a

Please sign in to comment.