remove isAdmin API
This commit is contained in:
@@ -6,11 +6,9 @@
|
|||||||
{{template "user_style" .}}
|
{{template "user_style" .}}
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
{{$isAdmin := .PixelAPI.UserIsAdmin}}
|
|
||||||
{{template "page_top" .}}
|
{{template "page_top" .}}
|
||||||
<div class="page_content">
|
<div class="page_content">
|
||||||
{{if $isAdmin}}
|
{{if and .Authenticated .User.IsAdmin}}
|
||||||
|
|
||||||
<div class="limit_width">
|
<div class="limit_width">
|
||||||
<a class="button" href="/admin/globals">Update global settings</a>
|
<a class="button" href="/admin/globals">Update global settings</a>
|
||||||
<a class="button" href="/admin/abuse">Block files</a>
|
<a class="button" href="/admin/abuse">Block files</a>
|
||||||
|
@@ -6,6 +6,7 @@
|
|||||||
{{if .Authenticated}}<a href="/user">{{.User.Username}}</a>
|
{{if .Authenticated}}<a href="/user">{{.User.Username}}</a>
|
||||||
<a href="/user/filemanager#files">My Files</a>
|
<a href="/user/filemanager#files">My Files</a>
|
||||||
<a href="/user/filemanager#lists">My Lists</a>
|
<a href="/user/filemanager#lists">My Lists</a>
|
||||||
|
{{if .User.IsAdmin}}<a href="/admin">Admin Panel</a>{{end}}
|
||||||
<a href="/logout">Log out</a>
|
<a href="/logout">Log out</a>
|
||||||
{{else}}
|
{{else}}
|
||||||
<a href="/login">Login</a>
|
<a href="/login">Login</a>
|
||||||
|
@@ -10,18 +10,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (wc *WebController) adminGlobalsForm(td *TemplateData, r *http.Request) (f Form) {
|
func (wc *WebController) adminGlobalsForm(td *TemplateData, r *http.Request) (f Form) {
|
||||||
if isAdmin, err := td.PixelAPI.UserIsAdmin(); err != nil {
|
if !td.Authenticated || !td.User.IsAdmin {
|
||||||
td.Title = err.Error()
|
return Form{Title: ";-)"}
|
||||||
return Form{Title: td.Title}
|
|
||||||
} else if !isAdmin {
|
|
||||||
td.Title = ";)"
|
|
||||||
return Form{Title: td.Title}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
td.Title = "Pixeldrain global configuration"
|
|
||||||
f = Form{
|
f = Form{
|
||||||
Name: "admin_globals",
|
Name: "admin_globals",
|
||||||
Title: td.Title,
|
Title: "Pixeldrain global configuration",
|
||||||
PreFormHTML: template.HTML("<p>Careful! The slightest typing error could bring the whole website down</p>"),
|
PreFormHTML: template.HTML("<p>Careful! The slightest typing error could bring the whole website down</p>"),
|
||||||
BackLink: "/admin",
|
BackLink: "/admin",
|
||||||
SubmitLabel: "Submit",
|
SubmitLabel: "Submit",
|
||||||
@@ -97,18 +92,13 @@ func (wc *WebController) adminGlobalsForm(td *TemplateData, r *http.Request) (f
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (wc *WebController) adminAbuseForm(td *TemplateData, r *http.Request) (f Form) {
|
func (wc *WebController) adminAbuseForm(td *TemplateData, r *http.Request) (f Form) {
|
||||||
if isAdmin, err := td.PixelAPI.UserIsAdmin(); err != nil {
|
if !td.Authenticated || !td.User.IsAdmin {
|
||||||
td.Title = err.Error()
|
return Form{Title: ";-)"}
|
||||||
return Form{Title: td.Title}
|
|
||||||
} else if !isAdmin {
|
|
||||||
td.Title = ";)"
|
|
||||||
return Form{Title: td.Title}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
td.Title = "Admin file removal"
|
|
||||||
f = Form{
|
f = Form{
|
||||||
Name: "admin_file_removal",
|
Name: "admin_file_removal",
|
||||||
Title: td.Title,
|
Title: "Admin file removal",
|
||||||
PreFormHTML: template.HTML("<p>Paste any pixeldrain file links in here to remove them</p>"),
|
PreFormHTML: template.HTML("<p>Paste any pixeldrain file links in here to remove them</p>"),
|
||||||
Fields: []Field{
|
Fields: []Field{
|
||||||
{
|
{
|
||||||
|
@@ -47,10 +47,9 @@ func (wc *WebController) registerForm(td *TemplateData, r *http.Request) (f Form
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Construct the form
|
// Construct the form
|
||||||
td.Title = "Register a new pixeldrain account"
|
|
||||||
f = Form{
|
f = Form{
|
||||||
Name: "register",
|
Name: "register",
|
||||||
Title: td.Title,
|
Title: "Register a new pixeldrain account",
|
||||||
Fields: []Field{
|
Fields: []Field{
|
||||||
{
|
{
|
||||||
Name: "username",
|
Name: "username",
|
||||||
@@ -128,7 +127,6 @@ func (wc *WebController) registerForm(td *TemplateData, r *http.Request) (f Form
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (wc *WebController) loginForm(td *TemplateData, r *http.Request) (f Form) {
|
func (wc *WebController) loginForm(td *TemplateData, r *http.Request) (f Form) {
|
||||||
td.Title = "Login"
|
|
||||||
f = Form{
|
f = Form{
|
||||||
Name: "login",
|
Name: "login",
|
||||||
Title: "Log in to your pixeldrain account",
|
Title: "Log in to your pixeldrain account",
|
||||||
@@ -186,10 +184,9 @@ func (wc *WebController) loginForm(td *TemplateData, r *http.Request) (f Form) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (wc *WebController) passwordResetForm(td *TemplateData, r *http.Request) (f Form) {
|
func (wc *WebController) passwordResetForm(td *TemplateData, r *http.Request) (f Form) {
|
||||||
td.Title = "Recover lost password"
|
|
||||||
f = Form{
|
f = Form{
|
||||||
Name: "password_reset",
|
Name: "password_reset",
|
||||||
Title: td.Title,
|
Title: "Recover lost password",
|
||||||
Fields: []Field{
|
Fields: []Field{
|
||||||
{
|
{
|
||||||
Name: "email",
|
Name: "email",
|
||||||
@@ -233,10 +230,9 @@ func (wc *WebController) passwordResetForm(td *TemplateData, r *http.Request) (f
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (wc *WebController) passwordResetConfirmForm(td *TemplateData, r *http.Request) (f Form) {
|
func (wc *WebController) passwordResetConfirmForm(td *TemplateData, r *http.Request) (f Form) {
|
||||||
td.Title = "Reset lost password"
|
|
||||||
f = Form{
|
f = Form{
|
||||||
Name: "password_reset_confirm",
|
Name: "password_reset_confirm",
|
||||||
Title: td.Title,
|
Title: "Reset lost password",
|
||||||
Fields: []Field{
|
Fields: []Field{
|
||||||
{
|
{
|
||||||
Name: "new_password",
|
Name: "new_password",
|
||||||
|
@@ -260,7 +260,7 @@ func (wc *WebController) serveForm(
|
|||||||
|
|
||||||
// The handler retuns the form which will be rendered
|
// The handler retuns the form which will be rendered
|
||||||
td.Form = handler(td, r)
|
td.Form = handler(td, r)
|
||||||
|
td.Title = td.Form.Title
|
||||||
td.Form.Username = td.User.Username
|
td.Form.Username = td.User.Username
|
||||||
|
|
||||||
// Execute the extra actions if any
|
// Execute the extra actions if any
|
||||||
|
Reference in New Issue
Block a user