Skip to content

Commit

Permalink
Merge pull request #16 from natrongmbh/revert-15-fix-auth
Browse files Browse the repository at this point in the history
Revert "new error handling"
  • Loading branch information
janlauber authored Sep 22, 2022
2 parents 29f9bd1 + 47ab146 commit c5d389a
Showing 1 changed file with 9 additions and 20 deletions.
29 changes: 9 additions & 20 deletions src/backend/controllers/authController.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ func LoggedIn(c *fiber.Ctx, githubCode string) error {
})
}
util.ErrorLogger.Printf("Error unmarshalling github teams data: %s", err)

// fill githubTeamsDataMap with empty map
githubTeamsDataMap = append(githubTeamsDataMap, map[string]interface{}{})
}

var githubUserDataMap map[string]interface{}
Expand All @@ -118,29 +115,21 @@ func LoggedIn(c *fiber.Ctx, githubCode string) error {
}
}

ghLogin, ok := githubUserDataMap["login"].(string)
if !ok {
return c.Status(500).JSON(fiber.Map{
"message": "Internal server error",
"error": "github login is not a string",
})
}

ghName, ok := githubUserDataMap["name"].(string)
if !ok {
ghName = ghLogin
// check if githubUserDataMap["name"].(string) is not nil
if githubUserDataMap["name"] == nil {
githubUserDataMap["name"] = githubUserDataMap["login"]
}

ghEmail, ok := githubUserDataMap["email"].(string)
if !ok {
ghEmail = ""
// check if email is not nil
if githubUserDataMap["email"] == nil {
githubUserDataMap["email"] = ""
}

githubUser := models.GithubUser{
ID: githubUserDataMap["id"].(float64),
Login: ghLogin,
Email: ghEmail,
Name: ghName,
Login: githubUserDataMap["login"].(string),
Email: githubUserDataMap["email"].(string),
Name: githubUserDataMap["name"].(string),
AvatarURL: githubUserDataMap["avatar_url"].(string),
GithubTeamSlugs: githubTeamSlugs,
GithubAccessToken: githubAccessToken,
Expand Down

0 comments on commit c5d389a

Please sign in to comment.