Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix name to consistent case #58

Merged
merged 1 commit into from
Oct 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions e2e_test/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ func TestSuccessRedirect(t *testing.T) {
},
LocalServerReadyChan: openBrowserCh,
LocalServerMiddleware: loggingMiddleware(t),
SuccessRedirectUrl: sr.URL + "/success",
FailureRedirectUrl: sr.URL + "/failure",
SuccessRedirectURL: sr.URL + "/success",
FailureRedirectURL: sr.URL + "/failure",
Logf: t.Logf,
}
token, err := oauth2cli.GetToken(ctx, cfg)
Expand Down
4 changes: 2 additions & 2 deletions e2e_test/error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ func TestFailureRedirect(t *testing.T) {
},
},
LocalServerReadyChan: openBrowserCh,
SuccessRedirectUrl: sr.URL + "/success",
FailureRedirectUrl: sr.URL + "/failure",
SuccessRedirectURL: sr.URL + "/success",
FailureRedirectURL: sr.URL + "/failure",
Logf: t.Logf,
}
_, err := oauth2cli.GetToken(ctx, cfg)
Expand Down
8 changes: 4 additions & 4 deletions oauth2cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ type Config struct {
LocalServerReadyChan chan<- string

// Redirect URL upon successful login
SuccessRedirectUrl string
SuccessRedirectURL string
// Redirect URL upon failed login
FailureRedirectUrl string
FailureRedirectURL string

// Logger function for debug.
Logf func(format string, args ...interface{})
Expand Down Expand Up @@ -123,8 +123,8 @@ func (c *Config) validateAndSetDefaults() error {
if c.LocalServerSuccessHTML == "" {
c.LocalServerSuccessHTML = DefaultLocalServerSuccessHTML
}
if (c.SuccessRedirectUrl != "" && c.FailureRedirectUrl == "") ||
(c.SuccessRedirectUrl == "" && c.FailureRedirectUrl != "") {
if (c.SuccessRedirectURL != "" && c.FailureRedirectURL == "") ||
(c.SuccessRedirectURL == "" && c.FailureRedirectURL != "") {
return fmt.Errorf("when using success and failure redirect URLs, set both URLs")
}
if c.Logf == nil {
Expand Down
8 changes: 4 additions & 4 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ func (h *localServerHandler) handleCodeResponse(w http.ResponseWriter, r *http.R
return &authorizationResponse{err: fmt.Errorf("state does not match (wants %s but got %s)", h.config.State, state)}
}

if h.config.SuccessRedirectUrl != "" {
http.Redirect(w, r, h.config.SuccessRedirectUrl, http.StatusFound)
if h.config.SuccessRedirectURL != "" {
http.Redirect(w, r, h.config.SuccessRedirectURL, http.StatusFound)
} else {
w.Header().Add("Content-Type", "text/html")
if _, err := fmt.Fprintf(w, h.config.LocalServerSuccessHTML); err != nil {
Expand All @@ -167,8 +167,8 @@ func (h *localServerHandler) handleErrorResponse(w http.ResponseWriter, r *http.
}

func (h *localServerHandler) authorizationError(w http.ResponseWriter, r *http.Request) {
if h.config.FailureRedirectUrl != "" {
http.Redirect(w, r, h.config.FailureRedirectUrl, http.StatusFound)
if h.config.FailureRedirectURL != "" {
http.Redirect(w, r, h.config.FailureRedirectURL, http.StatusFound)
} else {
http.Error(w, "authorization error", 500)
}
Expand Down