remove isAdmin API
This commit is contained in:
@@ -10,18 +10,13 @@ import (
|
||||
)
|
||||
|
||||
func (wc *WebController) adminGlobalsForm(td *TemplateData, r *http.Request) (f Form) {
|
||||
if isAdmin, err := td.PixelAPI.UserIsAdmin(); err != nil {
|
||||
td.Title = err.Error()
|
||||
return Form{Title: td.Title}
|
||||
} else if !isAdmin {
|
||||
td.Title = ";)"
|
||||
return Form{Title: td.Title}
|
||||
if !td.Authenticated || !td.User.IsAdmin {
|
||||
return Form{Title: ";-)"}
|
||||
}
|
||||
|
||||
td.Title = "Pixeldrain global configuration"
|
||||
f = Form{
|
||||
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>"),
|
||||
BackLink: "/admin",
|
||||
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) {
|
||||
if isAdmin, err := td.PixelAPI.UserIsAdmin(); err != nil {
|
||||
td.Title = err.Error()
|
||||
return Form{Title: td.Title}
|
||||
} else if !isAdmin {
|
||||
td.Title = ";)"
|
||||
return Form{Title: td.Title}
|
||||
if !td.Authenticated || !td.User.IsAdmin {
|
||||
return Form{Title: ";-)"}
|
||||
}
|
||||
|
||||
td.Title = "Admin file removal"
|
||||
f = Form{
|
||||
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>"),
|
||||
Fields: []Field{
|
||||
{
|
||||
|
@@ -47,10 +47,9 @@ func (wc *WebController) registerForm(td *TemplateData, r *http.Request) (f Form
|
||||
}
|
||||
|
||||
// Construct the form
|
||||
td.Title = "Register a new pixeldrain account"
|
||||
f = Form{
|
||||
Name: "register",
|
||||
Title: td.Title,
|
||||
Title: "Register a new pixeldrain account",
|
||||
Fields: []Field{
|
||||
{
|
||||
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) {
|
||||
td.Title = "Login"
|
||||
f = Form{
|
||||
Name: "login",
|
||||
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) {
|
||||
td.Title = "Recover lost password"
|
||||
f = Form{
|
||||
Name: "password_reset",
|
||||
Title: td.Title,
|
||||
Title: "Recover lost password",
|
||||
Fields: []Field{
|
||||
{
|
||||
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) {
|
||||
td.Title = "Reset lost password"
|
||||
f = Form{
|
||||
Name: "password_reset_confirm",
|
||||
Title: td.Title,
|
||||
Title: "Reset lost password",
|
||||
Fields: []Field{
|
||||
{
|
||||
Name: "new_password",
|
||||
|
@@ -260,7 +260,7 @@ func (wc *WebController) serveForm(
|
||||
|
||||
// The handler retuns the form which will be rendered
|
||||
td.Form = handler(td, r)
|
||||
|
||||
td.Title = td.Form.Title
|
||||
td.Form.Username = td.User.Username
|
||||
|
||||
// Execute the extra actions if any
|
||||
|
Reference in New Issue
Block a user