1
0
mirror of https://github.com/raseels-repos/golang-saas-starter-kit.git synced 2025-07-17 01:42:36 +02:00

fix optional auth for middleware in session

This commit is contained in:
Lee Brown
2019-08-12 12:48:06 -08:00
parent c16ab0e3f9
commit 064cebd2ce

View File

@ -107,7 +107,11 @@ func authenticateSession(authenticator *auth.Authenticator, required bool) web.M
claims, err := authenticator.ParseClaims(tknStr)
if err != nil {
return weberror.NewError(ctx, err, http.StatusUnauthorized)
if required {
return weberror.NewError(ctx, err, http.StatusUnauthorized)
} else {
return nil
}
}
// Add claims to the context so they can be retrieved later.