fixed minor bug surrounding oauth error

This commit is contained in:
0xdcarns
2021-10-28 10:20:37 -04:00
parent f7156551b2
commit 5322c44a99
3 changed files with 26 additions and 5 deletions

View File

@@ -3,6 +3,7 @@ package auth
import (
"encoding/base64"
"encoding/json"
"fmt"
"net/http"
"github.com/gravitl/netmaker/logic"
@@ -65,6 +66,11 @@ func InitializeAuthProvider() string {
// HandleAuthCallback - handles oauth callback
func HandleAuthCallback(w http.ResponseWriter, r *http.Request) {
if auth_provider == nil {
w.Header().Set("Content-Type", "text/html; charset=utf-8")
fmt.Fprintln(w, oauthNotConfigured)
return
}
var functions = getCurrentAuthFunctions()
if functions == nil {
return
@@ -74,6 +80,16 @@ func HandleAuthCallback(w http.ResponseWriter, r *http.Request) {
// HandleAuthLogin - handles oauth login
func HandleAuthLogin(w http.ResponseWriter, r *http.Request) {
if auth_provider == nil {
var referer = r.Header.Get("referer")
if referer != "" {
http.Redirect(w, r, referer+"?oauth=callback-error", http.StatusTemporaryRedirect)
return
}
w.Header().Set("Content-Type", "text/html; charset=utf-8")
fmt.Fprintln(w, oauthNotConfigured)
return
}
var functions = getCurrentAuthFunctions()
if functions == nil {
return