|
|
|
@ -14,9 +14,8 @@ import (
@@ -14,9 +14,8 @@ import (
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
var ( |
|
|
|
|
store = sessions.NewCookieStore([]byte(os.Getenv("SESSION_KEY"))) |
|
|
|
|
toks = make(map[string]Tokens) |
|
|
|
|
acctLinks = make(map[string]linkedAccount) |
|
|
|
|
store = sessions.NewCookieStore([]byte(os.Getenv("SESSION_KEY"))) |
|
|
|
|
toks = make(map[string]Tokens) |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
func topWrapper(r *http.Request) string { |
|
|
|
@ -60,16 +59,16 @@ func greetUser(w http.ResponseWriter, r *http.Request) {
@@ -60,16 +59,16 @@ func greetUser(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
|
|
|
|
|
if loggedIn { |
|
|
|
|
bodyTemplate, _ := ioutil.ReadFile("./static/index.html") |
|
|
|
|
fmt.Fprintf(w, string(bodyTemplate)) |
|
|
|
|
fmt.Fprint(w, string(bodyTemplate)) |
|
|
|
|
} else { |
|
|
|
|
fmt.Fprintf(w, pageBuilder(r, "home")) |
|
|
|
|
fmt.Fprint(w, pageBuilder(r, "home")) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func passPage(w http.ResponseWriter, r *http.Request) { |
|
|
|
|
defer log.PanicSafe() |
|
|
|
|
log.LogInfo(fmt.Sprintf("%s called passPage", getSessionIdentifier(r))) |
|
|
|
|
fmt.Fprintf(w, pageBuilder(r, "pass")) |
|
|
|
|
fmt.Fprint(w, pageBuilder(r, "pass")) |
|
|
|
|
} |
|
|
|
|
func loginPage(w http.ResponseWriter, r *http.Request) { |
|
|
|
|
defer log.PanicSafe() |
|
|
|
@ -85,18 +84,18 @@ func loginPage(w http.ResponseWriter, r *http.Request) {
@@ -85,18 +84,18 @@ func loginPage(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
if err != nil { |
|
|
|
|
log.LogWarn("Error logging out from loginPage()") |
|
|
|
|
} |
|
|
|
|
fmt.Fprintf(w, pageBuilder(r, "home")) |
|
|
|
|
fmt.Fprint(w, pageBuilder(r, "home")) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
fmt.Fprintf(w, pageBuilder(r, "login")) |
|
|
|
|
fmt.Fprint(w, pageBuilder(r, "login")) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func notFoundPage(w http.ResponseWriter, r *http.Request) { |
|
|
|
|
defer log.PanicSafe() |
|
|
|
|
go log.LogWarn(fmt.Sprintf("%s triggered notFoundPage", getSessionIdentifier(r))) |
|
|
|
|
fmt.Fprintf(w, topWrapper(r)) |
|
|
|
|
fmt.Fprint(w, topWrapper(r)) |
|
|
|
|
|
|
|
|
|
fmt.Fprintf(w, card("Oops! That Page Was Not found.", |
|
|
|
|
fmt.Fprint(w, card("Oops! That Page Was Not found.", |
|
|
|
|
"Sorry, a 404 error has occured. The requested page not found! <br><br>"+ |
|
|
|
|
"<iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/t3otBjVZzT0\" frameborder=\"0\" allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen></iframe>", |
|
|
|
|
"<div class=\"error-actions\"><a href=\"/\" class=\"btn btn-primary btn-lg\"><span class=\"glyphicon glyphicon-home\"></span>Take Me Home </a> <a href=\"mailto://rudi@nmare.net\" class=\"btn btn-default btn-lg\"><span class=\"glyphicon glyphicon-envelope\"></span> Contact Support </a></div>")) |
|
|
|
@ -126,7 +125,7 @@ func getPending(w http.ResponseWriter, r *http.Request) {
@@ -126,7 +125,7 @@ func getPending(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
log.LogErrorType(err) |
|
|
|
|
notFoundPage(w, r) |
|
|
|
|
} |
|
|
|
|
fmt.Fprintf(w, string(pending)) |
|
|
|
|
fmt.Fprint(w, string(pending)) |
|
|
|
|
} else { |
|
|
|
|
notFoundPage(w, r) |
|
|
|
|
} |
|
|
|
@ -140,7 +139,7 @@ func getConfig(w http.ResponseWriter, r *http.Request) {
@@ -140,7 +139,7 @@ func getConfig(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
log.LogErrorType(err) |
|
|
|
|
notFoundPage(w, r) |
|
|
|
|
} |
|
|
|
|
fmt.Fprintf(w, string(pending)) |
|
|
|
|
fmt.Fprint(w, string(pending)) |
|
|
|
|
} else { |
|
|
|
|
notFoundPage(w, r) |
|
|
|
|
} |
|
|
|
@ -154,7 +153,7 @@ func getProbations(w http.ResponseWriter, r *http.Request) {
@@ -154,7 +153,7 @@ func getProbations(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
log.LogErrorType(err) |
|
|
|
|
notFoundPage(w, r) |
|
|
|
|
} |
|
|
|
|
fmt.Fprintf(w, string(pending)) |
|
|
|
|
fmt.Fprint(w, string(pending)) |
|
|
|
|
} else { |
|
|
|
|
notFoundPage(w, r) |
|
|
|
|
} |
|
|
|
@ -193,7 +192,7 @@ func getVerifications(w http.ResponseWriter, r *http.Request) {
@@ -193,7 +192,7 @@ func getVerifications(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
if err != nil { |
|
|
|
|
log.LogErrorType(err) |
|
|
|
|
} |
|
|
|
|
fmt.Fprintf(w, string(verifications)) |
|
|
|
|
fmt.Fprint(w, string(verifications)) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func getUser(w http.ResponseWriter, r *http.Request) { |
|
|
|
@ -215,16 +214,7 @@ func getUser(w http.ResponseWriter, r *http.Request) {
@@ -215,16 +214,7 @@ func getUser(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
if err != nil { |
|
|
|
|
log.LogErrorType(err) |
|
|
|
|
} |
|
|
|
|
fmt.Fprintf(w, string(ret)) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func getVerification(w http.ResponseWriter, r *http.Request) { |
|
|
|
|
loggedIn, _ := detectUser(r, "getVerification") |
|
|
|
|
if !loggedIn { |
|
|
|
|
notFoundPage(w, r) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
http.ServeFile(w, r, r.URL.Path) |
|
|
|
|
fmt.Fprint(w, string(ret)) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func runWeb() { |
|
|
|
|