33 lines
816 B
Go
33 lines
816 B
Go
package handler
|
|
|
|
import (
|
|
"github.com/gorilla/csrf"
|
|
"net/http"
|
|
"picgo/corelib"
|
|
"picgo/data"
|
|
"picgo/model"
|
|
)
|
|
|
|
func UserHandler(w http.ResponseWriter, r *http.Request) {
|
|
if r.Method == "GET" {
|
|
var (
|
|
err error
|
|
user model.SysUser
|
|
)
|
|
username := r.Context().Value("username").(string)
|
|
if user, err = data.SysUserGetCacheByUsername(username); err != nil {
|
|
http.Error(w, "IndexHandler SysUserGetCacheByUsername Error", http.StatusInternalServerError)
|
|
return
|
|
}
|
|
tmpData := map[string]interface{}{
|
|
csrf.TemplateTag: csrf.TemplateField(r),
|
|
}
|
|
tmpData["Title"] = "用户管理"
|
|
tmpData["Active"] = r.URL.Path
|
|
tmpData["IsSuper"] = user.IsSuper
|
|
w.Header().Add("X-CSRF-Token", csrf.Token(r))
|
|
corelib.TemplateHandler(w, tmpData, "layout.html", "view/layout.html", "view/user.html")
|
|
|
|
}
|
|
}
|