Skip to content

Commit

Permalink
Remove unused user fields (thomseddon#141)
Browse files Browse the repository at this point in the history
These aren't actually used anywhere and can result in a parse error
if the ID field isn't a string
  • Loading branch information
thomseddon authored Jun 29, 2020
1 parent 529e28d commit be2b4ba
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 19 deletions.
3 changes: 0 additions & 3 deletions internal/provider/google_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,5 @@ func TestGoogleGetUser(t *testing.T) {
user, err := p.GetUser("123456789")
assert.Nil(err)

assert.Equal("1", user.ID)
assert.Equal("example@example.com", user.Email)
assert.True(user.Verified)
assert.Equal("example.com", user.Hd)
}
11 changes: 1 addition & 10 deletions internal/provider/oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,9 @@ func (o *OIDC) GetUser(token string) (User, error) {
}

// Extract custom claims
var claims struct {
ID string `json:"sub"`
Email string `json:"email"`
Verified bool `json:"email_verified"`
}
if err := idToken.Claims(&claims); err != nil {
if err := idToken.Claims(&user); err != nil {
return user, err
}

user.ID = claims.ID
user.Email = claims.Email
user.Verified = claims.Verified

return user, nil
}
2 changes: 0 additions & 2 deletions internal/provider/oidc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,7 @@ func TestOIDCGetUser(t *testing.T) {
// Get user
user, err := provider.GetUser(token)
assert.Nil(err)
assert.Equal("1", user.ID)
assert.Equal("example@example.com", user.Email)
assert.True(user.Verified)
}

// Utils
Expand Down
5 changes: 1 addition & 4 deletions internal/provider/providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ type token struct {

// User is the authenticated user
type User struct {
ID string `json:"id"`
Email string `json:"email"`
Verified bool `json:"verified_email"`
Hd string `json:"hd"`
Email string `json:"email"`
}

// OAuthProvider is a provider using the oauth2 library
Expand Down

0 comments on commit be2b4ba

Please sign in to comment.