Merge pull request #107 from george-e-shaw-iv/master

Redirect already authenticated users away from the login page
This commit is contained in:
George Shaw 2017-12-07 16:06:56 -06:00 committed by GitHub
commit 461f0caf5d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View file

@ -7,6 +7,7 @@ import (
"strconv"
"github.com/Ennovar/gPanel/pkg/routing"
"strings"
)
// ServeHTTP function routes all requests for the private webhost server. It is used in the main
@ -19,6 +20,12 @@ func (con *Controller) ServeHTTP(res http.ResponseWriter, req *http.Request) {
path = (con.DocumentRoot + path)
}
if strings.HasSuffix(path, "index.html") {
if con.checkAuth(res, req) == true {
http.Redirect(res, req, "gPanel.html", http.StatusFound)
}
}
if reqAuth(path) {
if !con.checkAuth(res, req) {
con.AccountLogger.Println(path + "::" + strconv.Itoa(http.StatusUnauthorized) + "::" + http.StatusText(http.StatusUnauthorized))

View file

@ -7,6 +7,7 @@ import (
"strconv"
"github.com/Ennovar/gPanel/pkg/routing"
"strings"
)
func (con *Controller) ServeHTTP(res http.ResponseWriter, req *http.Request) {
@ -17,6 +18,12 @@ func (con *Controller) ServeHTTP(res http.ResponseWriter, req *http.Request) {
path = (con.Directory + con.DocumentRoot + path)
}
if strings.HasSuffix(path, "index.html") {
if con.checkAuth(res, req) == true {
http.Redirect(res, req, "gPanel.html", http.StatusFound)
}
}
if reqAuth(path) {
if !con.checkAuth(res, req) {
con.ServerLogger.Println(path + "::" + strconv.Itoa(http.StatusUnauthorized) + "::" + http.StatusText(http.StatusUnauthorized))