2023-07-21 04:37:18 +00:00
|
|
|
/*
|
|
|
|
home show the home page
|
|
|
|
*/
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import "net/http"
|
|
|
|
|
|
|
|
type HomePageData struct {
|
2023-07-24 09:05:05 +00:00
|
|
|
Login *LoginStatus
|
|
|
|
BaseDN string
|
|
|
|
Org string
|
|
|
|
CanAdmin bool
|
2023-07-24 14:28:22 +00:00
|
|
|
LoggedIn bool
|
2023-07-21 04:37:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func handleHome(w http.ResponseWriter, r *http.Request) {
|
2023-07-25 12:53:14 +00:00
|
|
|
templateHome := getTemplate("home.html")
|
2023-07-21 04:37:18 +00:00
|
|
|
|
|
|
|
login := checkLogin(w, r)
|
|
|
|
if login == nil {
|
2023-07-25 13:14:12 +00:00
|
|
|
status := handleLogin(w, r)
|
|
|
|
if status == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
login = checkLogin(w, r)
|
2023-07-21 04:37:18 +00:00
|
|
|
}
|
2023-07-25 12:34:19 +00:00
|
|
|
|
2023-07-25 13:18:20 +00:00
|
|
|
can_admin := false
|
|
|
|
if login != nil {
|
2023-07-25 13:22:19 +00:00
|
|
|
can_admin = login.CanAdmin
|
2023-07-25 13:18:20 +00:00
|
|
|
}
|
|
|
|
|
2023-07-25 12:53:14 +00:00
|
|
|
data := HomePageData{
|
2023-07-25 12:34:19 +00:00
|
|
|
Login: login,
|
|
|
|
BaseDN: config.BaseDN,
|
|
|
|
Org: config.Org,
|
2023-07-25 13:18:20 +00:00
|
|
|
CanAdmin: can_admin,
|
2023-07-25 12:34:19 +00:00
|
|
|
LoggedIn: true,
|
|
|
|
}
|
|
|
|
templateHome.Execute(w, data)
|
|
|
|
|
2023-07-21 04:37:18 +00:00
|
|
|
}
|