From 8b059ac8771f231dc6d005951e2bd3e9bcb7633d Mon Sep 17 00:00:00 2001 From: Azareal Date: Fri, 3 Apr 2020 08:24:32 +1000 Subject: [PATCH] other mfa store tests save a few bytes --- common/errors.go | 2 +- common/topic_store.go | 2 +- common/user_store.go | 2 +- common/widget_search_and_filter.go | 6 +++--- misc_test.go | 7 +++++++ templates/account_own_edit.html | 10 +++++----- templates/account_own_edit_mfa_setup.html | 2 +- templates/convo_row_alt.html | 14 +++++++------- templates/panel_themes_widgets.html | 10 +++++----- templates/panel_themes_widgets_widget.html | 8 ++++---- templates/topics.html | 2 +- 11 files changed, 36 insertions(+), 29 deletions(-) diff --git a/common/errors.go b/common/errors.go index f74cd809..d4405ff7 100644 --- a/common/errors.go +++ b/common/errors.go @@ -181,7 +181,7 @@ func InternalErrorXML(err error, w http.ResponseWriter, r *http.Request) RouteEr func SilentInternalErrorXML(err error, w http.ResponseWriter, r *http.Request) RouteError { w.Header().Set("Content-Type", "application/xml") w.WriteHeader(500) - w.Write([]byte(` + w.Write([]byte(` ` + phrases.GetErrorPhrase("internal_error_body") + ``)) log.Print("InternalError: ", err) return HandledRouteError() diff --git a/common/topic_store.go b/common/topic_store.go index 8c758a16..5b7c720a 100644 --- a/common/topic_store.go +++ b/common/topic_store.go @@ -64,7 +64,7 @@ func NewDefaultTopicStore(cache TopicCache) (*DefaultTopicStore, error) { t := "topics" return &DefaultTopicStore{ cache: cache, - get: acc.Select(t).Columns("title, content, createdBy, createdAt, lastReplyBy, lastReplyAt, lastReplyID, is_closed, sticky, parentID, ip, views, postCount, likeCount, attachCount, poll, data").Where("tid=?").Prepare(), + get: acc.Select(t).Columns("title,content,createdBy,createdAt,lastReplyBy,lastReplyAt,lastReplyID,is_closed,sticky,parentID,ip,views,postCount,likeCount,attachCount,poll,data").Where("tid=?").Prepare(), exists: acc.Exists(t, "tid").Prepare(), count: acc.Count(t).Prepare(), countUser: acc.Count(t).Where("createdBy=?").Prepare(), diff --git a/common/user_store.go b/common/user_store.go index 5eb1f363..2724d022 100644 --- a/common/user_store.go +++ b/common/user_store.go @@ -53,7 +53,7 @@ func NewDefaultUserStore(cache UserCache) (*DefaultUserStore, error) { cache = NewNullUserCache() } u := "users" - allCols := "uid, name, group, active, is_super_admin, session, email, avatar, message, level, score, posts, liked, last_ip, temp_group, createdAt, enable_embeds" + allCols := "uid,name,group,active,is_super_admin,session,email,avatar,message,level,score,posts,liked,last_ip,temp_group,createdAt,enable_embeds" // TODO: Add an admin version of registerStmt with more flexibility? return &DefaultUserStore{ cache: cache, diff --git a/common/widget_search_and_filter.go b/common/widget_search_and_filter.go index 163cecb1..cefe7a0b 100644 --- a/common/widget_search_and_filter.go +++ b/common/widget_search_and_filter.go @@ -14,16 +14,16 @@ type searchAndFilter struct { func widgetSearchAndFilter(widget *Widget, hvars interface{}) (out string, err error) { header := hvars.(*Header) - user := header.CurrentUser + u := header.CurrentUser var forums []filterForum var canSee []int - if user.IsSuperAdmin { + if u.IsSuperAdmin { canSee, err = Forums.GetAllVisibleIDs() if err != nil { return "", err } } else { - group, err := Groups.Get(user.Group) + group, err := Groups.Get(u.Group) if err != nil { // TODO: Revisit this return "", errors.New("Something weird happened") diff --git a/misc_test.go b/misc_test.go index f897ae9f..2b0e1717 100644 --- a/misc_test.go +++ b/misc_test.go @@ -1841,6 +1841,13 @@ func TestMFAStore(t *testing.T) { it, err = c.MFAstore.Get(1) test(i) } + expectNilErr(t, it.Delete()) + _, err = c.MFAstore.Get(-1) + recordMustNotExist(t, err, "mfa uid -1 should not exist") + _, err = c.MFAstore.Get(0) + recordMustNotExist(t, err, "mfa uid 0 should not exist") + _, err = c.MFAstore.Get(1) + recordMustNotExist(t, err, "mfa uid 1 should not exist") } // TODO: Expand upon the valid characters which can go in URLs? diff --git a/templates/account_own_edit.html b/templates/account_own_edit.html index 60aad3cc..20bd005a 100644 --- a/templates/account_own_edit.html +++ b/templates/account_own_edit.html @@ -1,12 +1,12 @@ -
+
-
-
- - +
+
+ +
diff --git a/templates/account_own_edit_mfa_setup.html b/templates/account_own_edit_mfa_setup.html index b5bac8bf..4aa9fb5e 100644 --- a/templates/account_own_edit_mfa_setup.html +++ b/templates/account_own_edit_mfa_setup.html @@ -7,7 +7,7 @@
- +
{{.Something}}
diff --git a/templates/convo_row_alt.html b/templates/convo_row_alt.html index 4f14d4ba..9f7579f7 100644 --- a/templates/convo_row_alt.html +++ b/templates/convo_row_alt.html @@ -1,21 +1,21 @@ {{range .Posts}} -
+
- + - {{.User.Name}} - {{if .User.Tag}}{{.User.Tag}}{{end}} + {{.User.Name}} + {{if .User.Tag}}{{.User.Tag}}{{end}}
{{if .CanModify}} - + - + {{end}} - +
diff --git a/templates/panel_themes_widgets.html b/templates/panel_themes_widgets.html index ac05dbbd..cf7c0497 100644 --- a/templates/panel_themes_widgets.html +++ b/templates/panel_themes_widgets.html @@ -24,8 +24,8 @@ type Widget struct { {{$widget.Location}}
- - + + {{template "panel_themes_widgets_widget.html" $widget }}
@@ -39,13 +39,13 @@ type Widget struct {
- - + + {{template "panel_themes_widgets_widget.html" .BlankWidget }}
diff --git a/templates/panel_themes_widgets_widget.html b/templates/panel_themes_widgets_widget.html index 3b1f684c..9230b321 100644 --- a/templates/panel_themes_widgets_widget.html +++ b/templates/panel_themes_widgets_widget.html @@ -22,26 +22,26 @@
- +
- +
diff --git a/templates/topics.html b/templates/topics.html index 57c6c481..2780b88b 100644 --- a/templates/topics.html +++ b/templates/topics.html @@ -25,7 +25,7 @@
- {{else}}
{{end}} + {{else}}
{{end}}
{{end}}