Skip to content

Commit

Permalink
fix logged in issue
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Lauber <[email protected]>
  • Loading branch information
janlauber committed Jan 23, 2022
1 parent 93efc8d commit 6b0091c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions controllers/authController.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ func LoggedIn(c *fiber.Ctx, githubData string) error {
githubTeamSlugs = append(githubTeamSlugs, githubTeam["slug"].(string))
}

if githubTeamSlugs == nil {
// return unauthorized
return c.Status(401).JSON(fiber.Map{
"message": "Unauthorized",
})
}

claims := jwt.MapClaims{
"github_team_slugs": githubTeamSlugs,
}
Expand Down Expand Up @@ -93,6 +100,11 @@ func CheckAuth(c *fiber.Ctx) []string {

claims := token.Claims.(jwt.MapClaims)

if claims["github_team_slugs"] == nil {
util.WarningLogger.Printf("IP %s is not authorized", c.IP())
return nil
}

var githubTeamSlugs []string
for _, githubTeam := range claims["github_team_slugs"].([]interface{}) {
githubTeamSlugs = append(githubTeamSlugs, githubTeam.(string))
Expand Down

0 comments on commit 6b0091c

Please sign in to comment.