1
0

fix: provide a proper error message when viewing a link share with an invalid token

This commit is contained in:
kolaente
2023-04-17 11:08:38 +02:00
parent 10f71c29b2
commit aa43127e52
3 changed files with 36 additions and 4 deletions

View File

@ -86,10 +86,15 @@ func (share *LinkSharing) GetID() int64 {
// GetLinkShareFromClaims builds a link sharing object from jwt claims
func GetLinkShareFromClaims(claims jwt.MapClaims) (share *LinkSharing, err error) {
projectID, is := claims["project_id"].(float64)
if !is {
return nil, &ErrLinkShareTokenInvalid{}
}
share = &LinkSharing{}
share.ID = int64(claims["id"].(float64))
share.Hash = claims["hash"].(string)
share.ProjectID = int64(claims["project_id"].(float64))
share.ProjectID = int64(projectID)
share.Right = Right(claims["right"].(float64))
share.SharedByID = int64(claims["sharedByID"].(float64))
return