other mfa store tests

save a few bytes
This commit is contained in:
Azareal 2020-04-03 08:24:32 +10:00
parent 95d3f9ebe1
commit 8b059ac877
11 changed files with 36 additions and 29 deletions

View File

@ -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(`<?xml version="1.0" encoding="UTF-8"?>
w.Write([]byte(`<?xml version="1.0"encoding="UTF-8"?>
<error>` + phrases.GetErrorPhrase("internal_error_body") + `</error>`))
log.Print("InternalError: ", err)
return HandledRouteError()

View File

@ -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(),

View File

@ -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,

View File

@ -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")

View File

@ -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?

View File

@ -1,12 +1,12 @@
<form id="avatar_form" action="/user/edit/avatar/submit/?s={{.CurrentUser.Session}}" method="post" enctype="multipart/form-data"></form>
<form id="avatar_form"action="/user/edit/avatar/submit/?s={{.CurrentUser.Session}}"method="post"enctype="multipart/form-data"></form>
<div class="coldyn_block">
<div id="dash_left" class="coldyn_item">
<div class="rowitem">
<span id="dash_username">
<form id="dash_username_form" action="/user/edit/username/submit/?s={{.CurrentUser.Session}}" method="post"></form>
<form id="revoke_avatar_form" action="/user/edit/avatar/revoke/submit/?s={{.CurrentUser.Session}}" method="post"></form>
<input form="dash_username_form" name="new-name" value="{{.CurrentUser.Name}}">
<button form="dash_username_form" class="formbutton">{{lang "account_username_save"}}</button>
<form id="dash_username_form"action="/user/edit/username/submit/?s={{.CurrentUser.Session}}"method="post"></form>
<form id="revoke_avatar_form"action="/user/edit/avatar/revoke/submit/?s={{.CurrentUser.Session}}"method="post"></form>
<input form="dash_username_form"name="new-name"value="{{.CurrentUser.Name}}">
<button form="dash_username_form"class="formbutton">{{lang "account_username_save"}}</button>
</span>
<img src="{{.CurrentUser.Avatar}}"height="128px">
<span id="dash_avatar_buttons">

View File

@ -7,7 +7,7 @@
</div>
<div class="colstack_item the_form">
<form action="/user/edit/mfa/setup/submit/?s={{.CurrentUser.Session}}" method="post">
<input name="code" value="{{.Something}}" type="hidden">
<input name="code"value="{{.Something}}"type="hidden">
<div class="formrow real_first_child">
<div class="formitem formlabel"><a>{{lang "account_mfa_setup_explanation"}}</a></div>
<div class="formitem formlabel">{{.Something}}</div>

View File

@ -1,21 +1,21 @@
{{range .Posts}}
<div id="post-{{.ID}}" class="rowitem passive deletable_block editable_parent comment {{.ClassName}}">
<div id="post-{{.ID}}"class="rowitem passive deletable_block editable_parent comment {{.ClassName}}">
<div class="topRow">
<div class="userbit">
<img src="{{.User.MicroAvatar}}" alt="Avatar" title="{{.User.Name}}'s Avatar" aria-hidden="true">
<img src="{{.User.MicroAvatar}}"alt="Avatar"title="{{.User.Name}}'s Avatar"aria-hidden="true">
<span class="nameAndTitle">
<a href="{{.User.Link}}" class="real_username username">{{.User.Name}}</a>
{{if .User.Tag}}<a class="username hide_on_mobile user_tag" style="float:right;">{{.User.Tag}}</a>{{end}}
<a href="{{.User.Link}}"class="real_username username">{{.User.Name}}</a>
{{if .User.Tag}}<a class="username hide_on_mobile user_tag"style="float:right;">{{.User.Tag}}</a>{{end}}
</span>
</div>
<span class="controls">
{{if .CanModify}}
<a href="/user/convo/edit/submit/{{.ID}}?s={{$.CurrentUser.Session}}" class="mod_button" title="{{lang "profile.comments_edit_tooltip"}}" aria-label="{{lang "profile.comments_edit_aria"}}"><button class="username edit_item edit_label"></button></a>
<a href="/user/convo/edit/submit/{{.ID}}?s={{$.CurrentUser.Session}}"class="mod_button"title="{{lang "profile.comments_edit_tooltip"}}" aria-label="{{lang "profile.comments_edit_aria"}}"><button class="username edit_item edit_label"></button></a>
<a href="/user/convo/delete/submit/{{.ID}}?s={{$.CurrentUser.Session}}" class="mod_button" title="{{lang "profile.comments_delete_tooltip"}}" aria-label="{{lang "profile.comments_delete_aria"}}"><button class="username delete_item delete_label"></button></a>
<a href="/user/convo/delete/submit/{{.ID}}?s={{$.CurrentUser.Session}}"class="mod_button"title="{{lang "profile.comments_delete_tooltip"}}" aria-label="{{lang "profile.comments_delete_aria"}}"><button class="username delete_item delete_label"></button></a>
{{end}}
<a class="mod_button" href="/report/submit/{{.ID}}?s={{$.CurrentUser.Session}}&type=convo-reply"><button class="username report_item flag_label" title="{{lang "profile.comments_report_tooltip"}}" aria-label="{{lang "profile.comments_report_aria"}}"></button></a>
<a class="mod_button"href="/report/submit/{{.ID}}?s={{$.CurrentUser.Session}}&type=convo-reply"><button class="username report_item flag_label"title="{{lang "profile.comments_report_tooltip"}}" aria-label="{{lang "profile.comments_report_aria"}}"></button></a>
</span>
</div>
<div class="content_column">

View File

@ -24,8 +24,8 @@ type Widget struct {
<a class="panel_compacttext to_right">{{$widget.Location}}</a>
</div>
<div class="widget_edit show_on_block_edit">
<form action="/panel/themes/widgets/edit/submit/{{$widget.ID}}" method="post">
<input class="wside" name="wside" value="{{$name}}" type="hidden">
<form action="/panel/themes/widgets/edit/submit/{{$widget.ID}}"method="post">
<input class="wside"name="wside"value="{{$name}}"type="hidden">
{{template "panel_themes_widgets_widget.html" $widget }}
</form>
</div>
@ -39,13 +39,13 @@ type Widget struct {
<div id="widgetTmpl">
<div class="rowitem panel_compactrow editable_parent widget_item blank_widget bg_red">
<div class="widget_normal editable_block hide_on_block_edit">
<a href="#" class="panel_upshift">{{.BlankWidget.Type}} <span class="widget_disabled">({{lang "panel_themes_widgets_disabled"}})</span></a>
<a href="#"class="panel_upshift">{{.BlankWidget.Type}} <span class="widget_disabled">({{lang "panel_themes_widgets_disabled"}})</span></a>
<a class="panel_compacttext to_right">{{.BlankWidget.Location}}</a>
</div>
<div class="widget_edit show_on_block_edit">
<form action="/panel/themes/widgets/create/submit/" method="post">
<input name="s" value="{{.CurrentUser.Session}}" type="hidden">
<input class="wside" name="wside" value="" type="hidden">
<input name="s"value="{{.CurrentUser.Session}}"type="hidden">
<input class="wside"name="wside"value=""type="hidden">
{{template "panel_themes_widgets_widget.html" .BlankWidget }}
</form>
</div>

View File

@ -22,26 +22,26 @@
<div class="formrow">
<div class="formitem formlabel"><a>{{lang "panel_themes_widgets_location"}}</a></div>
<div class="formitem">
<input name="wlocation" value="{{.Location}}">
<input name="wlocation"value="{{.Location}}">
</div>
</div>
<div class="wtypes wtype_{{.Type}}">
<div class="formrow w_simple w_about">
<div class="formitem formlabel"><a>{{lang "panel_themes_widgets_name"}}</a></div>
<div class="formitem">
<input name="wname" value="{{index .Data "Name"}}">
<input name="wname"value="{{index .Data "Name"}}">
</div>
</div>
<div class="formrow w_simple w_about">
<div class="formitem formlabel"><a>{{lang "panel_themes_widgets_body"}}</a></div>
<div class="formitem">
<textarea name="wtext" class="wtext">{{index .Data "Text"}}</textarea>
<textarea name="wtext"class="wtext">{{index .Data "Text"}}</textarea>
</div>
</div>
<div class="formrow w_default">
<div class="formitem formlabel"><a>{{lang "panel_themes_widgets_raw_body"}}</a></div>
<div class="formitem">
<textarea name="wbody" class="rwtext">{{.RawBody}}</textarea>
<textarea name="wbody"class="rwtext">{{.RawBody}}</textarea>
</div>
</div>
</div>

View File

@ -25,7 +25,7 @@
<div class="opt mod_opt" title="{{lang "topic_list.moderate_tooltip"}}">
<a class="moderate_link" href="#" aria-label="{{lang "topic_list.moderate_aria"}}"></a>
</div>
{{else}}<div class="opt locked_opt" title="{{lang "topics_locked_tooltip"}}" aria-label="{{lang "topics_locked_aria"}}"><a></a></div>{{end}}
{{else}}<div class="opt locked_opt"title="{{lang "topics_locked_tooltip"}}" aria-label="{{lang "topics_locked_aria"}}"><a></a></div>{{end}}
</div><div style="clear:both;"></div>
{{end}}
</div>