Skip to content
This repository has been archived by the owner on Aug 16, 2022. It is now read-only.

Commit

Permalink
support overriding name
Browse files Browse the repository at this point in the history
  • Loading branch information
rot1024 committed Apr 6, 2022
1 parent 8a24cfe commit a375a5d
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions internal/usecase/interactor/user_signup.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,16 @@ func (i *User) SignupOIDC(ctx context.Context, inp interfaces.SignupOIDCParam) (
return nil, nil, err
}
sub = ui.Sub
name = ui.Name
email = ui.Email
if name == "" {
name = ui.Nickname
}
if name == "" {
name = ui.Name
}
if name == "" {
name = ui.Email
}
}

tx, err := i.transaction.Begin()
Expand Down Expand Up @@ -266,10 +274,11 @@ func getOpenIDConfiguration(ctx context.Context, iss string) (c OpenIDConfigurat
}

type UserInfo struct {
Sub string `json:"sub"`
Name string `json:"name"`
Email string `json:"email"`
Error string `json:"error"`
Sub string `json:"sub"`
Name string `json:"name"`
Nickname string `json:"nickname"`
Email string `json:"email"`
Error string `json:"error"`
}

func getUserInfo(ctx context.Context, url, accessToken string) (ui UserInfo, err error) {
Expand Down Expand Up @@ -308,10 +317,6 @@ func getUserInfo(ctx context.Context, url, accessToken string) (ui UserInfo, err
err = fmt.Errorf("could not get user info: invalid response")
return
}
if ui.Name == "" {
err = fmt.Errorf("could not get user info: profile scope missing")
return
}
if ui.Email == "" {
err = fmt.Errorf("could not get user info: email scope missing")
return
Expand Down

0 comments on commit a375a5d

Please sign in to comment.