Ajout d'une page 'Non autorisée' et redirection automatique vers celle ci en cas d'accès via un compte non autorisé

This commit is contained in:
2020-10-12 10:05:04 +02:00
parent 7a6eedab9d
commit 0859202987
4 changed files with 52 additions and 10 deletions

View File

@ -1,7 +1,6 @@
package route
import (
"fmt"
"net/http"
"forge.cadoles.com/Cadoles/daddy/internal/auth"
@ -80,11 +79,8 @@ func handleLoginCallback(w http.ResponseWriter, r *http.Request) {
}
if !authorized {
message := fmt.Sprintf(
"You are not authorized to access this application. Disconnect by navigating to %s.",
"http://"+r.Host+"/logout",
)
http.Error(w, message, http.StatusForbidden)
redirectURL := conf.HTTP.FrontendURL + "/unauthorized"
http.Redirect(w, r, redirectURL, http.StatusTemporaryRedirect)
return
}