remove need of frontend url for error pages

This commit is contained in:
Anish Mukherjee
2022-12-23 17:46:45 +05:30
parent 6d54851ed4
commit 1a442aa299
7 changed files with 25 additions and 31 deletions

View File

@@ -37,16 +37,13 @@ func initGithub(redirectURL string, clientID string, clientSecret string) {
func handleGithubLogin(w http.ResponseWriter, r *http.Request) {
var oauth_state_string = logic.RandomString(user_signin_length)
if auth_provider == nil && servercfg.GetFrontendURL() != "" {
http.Redirect(w, r, servercfg.GetFrontendURL()+"/login?oauth=callback-error", http.StatusTemporaryRedirect)
return
} else if auth_provider == nil {
fmt.Fprintf(w, "%s", []byte("no frontend URL was provided and an OAuth login was attempted\nplease reconfigure server to use OAuth or use basic credentials"))
if auth_provider == nil {
logic.HandleOauthNotConfigured(w)
return
}
if err := logic.SetState(oauth_state_string); err != nil {
http.Redirect(w, r, servercfg.GetFrontendURL()+"/login?oauth=callback-error", http.StatusTemporaryRedirect)
logic.HandleOauthNotConfigured(w)
return
}
@@ -60,7 +57,7 @@ func handleGithubCallback(w http.ResponseWriter, r *http.Request) {
var content, err = getGithubUserInfo(rState, rCode)
if err != nil {
logger.Log(1, "error when getting user info from github:", err.Error())
http.Redirect(w, r, servercfg.GetFrontendURL()+"/login?oauth=callback-error", http.StatusTemporaryRedirect)
logic.HandleOauthNotConfigured(w)
return
}
_, err = logic.GetUser(content.Login)