Renamed the middleware functions.

This commit is contained in:
Azareal 2017-09-10 18:39:16 +01:00
parent 583c3b16bd
commit b289b52210
5 changed files with 82 additions and 83 deletions

View File

@ -38,7 +38,7 @@ func route_edit_topic(w http.ResponseWriter, r *http.Request, user User) {
} }
// TODO: Add hooks to make use of headerLite // TODO: Add hooks to make use of headerLite
_, ok := SimpleForumSessionCheck(w, r, &user, oldTopic.ParentID) _, ok := SimpleForumUserCheck(w, r, &user, oldTopic.ParentID)
if !ok { if !ok {
return return
} }
@ -128,7 +128,7 @@ func route_delete_topic(w http.ResponseWriter, r *http.Request, user User) {
} }
// TODO: Add hooks to make use of headerLite // TODO: Add hooks to make use of headerLite
_, ok := SimpleForumSessionCheck(w, r, &user, topic.ParentID) _, ok := SimpleForumUserCheck(w, r, &user, topic.ParentID)
if !ok { if !ok {
return return
} }
@ -202,7 +202,7 @@ func route_stick_topic(w http.ResponseWriter, r *http.Request, user User) {
} }
// TODO: Add hooks to make use of headerLite // TODO: Add hooks to make use of headerLite
_, ok := SimpleForumSessionCheck(w, r, &user, topic.ParentID) _, ok := SimpleForumUserCheck(w, r, &user, topic.ParentID)
if !ok { if !ok {
return return
} }
@ -258,7 +258,7 @@ func route_unstick_topic(w http.ResponseWriter, r *http.Request, user User) {
} }
// TODO: Add hooks to make use of headerLite // TODO: Add hooks to make use of headerLite
_, ok := SimpleForumSessionCheck(w, r, &user, topic.ParentID) _, ok := SimpleForumUserCheck(w, r, &user, topic.ParentID)
if !ok { if !ok {
return return
} }
@ -339,7 +339,7 @@ func route_reply_edit_submit(w http.ResponseWriter, r *http.Request, user User)
} }
// TODO: Add hooks to make use of headerLite // TODO: Add hooks to make use of headerLite
_, ok := SimpleForumSessionCheck(w, r, &user, fid) _, ok := SimpleForumUserCheck(w, r, &user, fid)
if !ok { if !ok {
return return
} }
@ -390,7 +390,7 @@ func route_reply_delete_submit(w http.ResponseWriter, r *http.Request, user User
} }
// TODO: Add hooks to make use of headerLite // TODO: Add hooks to make use of headerLite
_, ok := SimpleForumSessionCheck(w, r, &user, fid) _, ok := SimpleForumUserCheck(w, r, &user, fid)
if !ok { if !ok {
return return
} }
@ -531,7 +531,7 @@ func route_profile_reply_delete_submit(w http.ResponseWriter, r *http.Request, u
} }
func route_ips(w http.ResponseWriter, r *http.Request, user User) { func route_ips(w http.ResponseWriter, r *http.Request, user User) {
headerVars, ok := SessionCheck(w, r, &user) headerVars, ok := UserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -636,7 +636,7 @@ func route_ips(w http.ResponseWriter, r *http.Request, user User) {
// TODO: This is being replaced with the new ban route system // TODO: This is being replaced with the new ban route system
/*func route_ban(w http.ResponseWriter, r *http.Request, user User) { /*func route_ban(w http.ResponseWriter, r *http.Request, user User) {
headerVars, ok := SessionCheck(w,r,&user) headerVars, ok := UserCheck(w,r,&user)
if !ok { if !ok {
return return
} }

View File

@ -15,7 +15,7 @@ import (
) )
func route_panel(w http.ResponseWriter, r *http.Request, user User) { func route_panel(w http.ResponseWriter, r *http.Request, user User) {
headerVars, stats, ok := PanelSessionCheck(w, r, &user) headerVars, stats, ok := PanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -181,7 +181,7 @@ func route_panel(w http.ResponseWriter, r *http.Request, user User) {
} }
func route_panel_forums(w http.ResponseWriter, r *http.Request, user User) { func route_panel_forums(w http.ResponseWriter, r *http.Request, user User) {
headerVars, stats, ok := PanelSessionCheck(w, r, &user) headerVars, stats, ok := PanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -219,7 +219,7 @@ func route_panel_forums(w http.ResponseWriter, r *http.Request, user User) {
} }
func route_panel_forums_create_submit(w http.ResponseWriter, r *http.Request, user User) { func route_panel_forums_create_submit(w http.ResponseWriter, r *http.Request, user User) {
_, ok := SimplePanelSessionCheck(w, r, &user) _, ok := SimplePanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -255,7 +255,7 @@ func route_panel_forums_create_submit(w http.ResponseWriter, r *http.Request, us
// TODO: Revamp this // TODO: Revamp this
func route_panel_forums_delete(w http.ResponseWriter, r *http.Request, user User, sfid string) { func route_panel_forums_delete(w http.ResponseWriter, r *http.Request, user User, sfid string) {
headerVars, stats, ok := PanelSessionCheck(w, r, &user) headerVars, stats, ok := PanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -299,7 +299,7 @@ func route_panel_forums_delete(w http.ResponseWriter, r *http.Request, user User
} }
func route_panel_forums_delete_submit(w http.ResponseWriter, r *http.Request, user User, sfid string) { func route_panel_forums_delete_submit(w http.ResponseWriter, r *http.Request, user User, sfid string) {
_, ok := SimplePanelSessionCheck(w, r, &user) _, ok := SimplePanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -331,7 +331,7 @@ func route_panel_forums_delete_submit(w http.ResponseWriter, r *http.Request, us
} }
func route_panel_forums_edit(w http.ResponseWriter, r *http.Request, user User, sfid string) { func route_panel_forums_edit(w http.ResponseWriter, r *http.Request, user User, sfid string) {
headerVars, stats, ok := PanelSessionCheck(w, r, &user) headerVars, stats, ok := PanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -381,7 +381,7 @@ func route_panel_forums_edit(w http.ResponseWriter, r *http.Request, user User,
} }
func route_panel_forums_edit_submit(w http.ResponseWriter, r *http.Request, user User, sfid string) { func route_panel_forums_edit_submit(w http.ResponseWriter, r *http.Request, user User, sfid string) {
_, ok := SimplePanelSessionCheck(w, r, &user) _, ok := SimplePanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -464,7 +464,7 @@ func route_panel_forums_edit_submit(w http.ResponseWriter, r *http.Request, user
} }
func route_panel_forums_edit_perms_submit(w http.ResponseWriter, r *http.Request, user User, sfid string) { func route_panel_forums_edit_perms_submit(w http.ResponseWriter, r *http.Request, user User, sfid string) {
_, ok := SimplePanelSessionCheck(w, r, &user) _, ok := SimplePanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -543,7 +543,7 @@ func route_panel_forums_edit_perms_submit(w http.ResponseWriter, r *http.Request
} }
func route_panel_settings(w http.ResponseWriter, r *http.Request, user User) { func route_panel_settings(w http.ResponseWriter, r *http.Request, user User) {
headerVars, stats, ok := PanelSessionCheck(w, r, &user) headerVars, stats, ok := PanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -608,7 +608,7 @@ func route_panel_settings(w http.ResponseWriter, r *http.Request, user User) {
} }
func route_panel_setting(w http.ResponseWriter, r *http.Request, user User, sname string) { func route_panel_setting(w http.ResponseWriter, r *http.Request, user User, sname string) {
headerVars, stats, ok := PanelSessionCheck(w, r, &user) headerVars, stats, ok := PanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -659,7 +659,7 @@ func route_panel_setting(w http.ResponseWriter, r *http.Request, user User, snam
} }
func route_panel_setting_edit(w http.ResponseWriter, r *http.Request, user User, sname string) { func route_panel_setting_edit(w http.ResponseWriter, r *http.Request, user User, sname string) {
headerLite, ok := SimplePanelSessionCheck(w, r, &user) headerLite, ok := SimplePanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -715,7 +715,7 @@ func route_panel_setting_edit(w http.ResponseWriter, r *http.Request, user User,
} }
func route_panel_word_filters(w http.ResponseWriter, r *http.Request, user User) { func route_panel_word_filters(w http.ResponseWriter, r *http.Request, user User) {
headerVars, stats, ok := PanelSessionCheck(w, r, &user) headerVars, stats, ok := PanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -738,7 +738,7 @@ func route_panel_word_filters(w http.ResponseWriter, r *http.Request, user User)
} }
func route_panel_word_filters_create(w http.ResponseWriter, r *http.Request, user User) { func route_panel_word_filters_create(w http.ResponseWriter, r *http.Request, user User) {
_, ok := SimplePanelSessionCheck(w, r, &user) _, ok := SimplePanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -779,7 +779,7 @@ func route_panel_word_filters_create(w http.ResponseWriter, r *http.Request, use
} }
func route_panel_word_filters_edit(w http.ResponseWriter, r *http.Request, user User, wfid string) { func route_panel_word_filters_edit(w http.ResponseWriter, r *http.Request, user User, wfid string) {
headerVars, stats, ok := PanelSessionCheck(w, r, &user) headerVars, stats, ok := PanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -803,7 +803,7 @@ func route_panel_word_filters_edit(w http.ResponseWriter, r *http.Request, user
} }
func route_panel_word_filters_edit_submit(w http.ResponseWriter, r *http.Request, user User, wfid string) { func route_panel_word_filters_edit_submit(w http.ResponseWriter, r *http.Request, user User, wfid string) {
_, ok := SimplePanelSessionCheck(w, r, &user) _, ok := SimplePanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -849,7 +849,7 @@ func route_panel_word_filters_edit_submit(w http.ResponseWriter, r *http.Request
} }
func route_panel_word_filters_delete_submit(w http.ResponseWriter, r *http.Request, user User, wfid string) { func route_panel_word_filters_delete_submit(w http.ResponseWriter, r *http.Request, user User, wfid string) {
_, ok := SimplePanelSessionCheck(w, r, &user) _, ok := SimplePanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -885,7 +885,7 @@ func route_panel_word_filters_delete_submit(w http.ResponseWriter, r *http.Reque
} }
func route_panel_plugins(w http.ResponseWriter, r *http.Request, user User) { func route_panel_plugins(w http.ResponseWriter, r *http.Request, user User) {
headerVars, stats, ok := PanelSessionCheck(w, r, &user) headerVars, stats, ok := PanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -914,7 +914,7 @@ func route_panel_plugins(w http.ResponseWriter, r *http.Request, user User) {
} }
func route_panel_plugins_activate(w http.ResponseWriter, r *http.Request, user User, uname string) { func route_panel_plugins_activate(w http.ResponseWriter, r *http.Request, user User, uname string) {
_, ok := SimplePanelSessionCheck(w, r, &user) _, ok := SimplePanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -990,7 +990,7 @@ func route_panel_plugins_activate(w http.ResponseWriter, r *http.Request, user U
} }
func route_panel_plugins_deactivate(w http.ResponseWriter, r *http.Request, user User, uname string) { func route_panel_plugins_deactivate(w http.ResponseWriter, r *http.Request, user User, uname string) {
_, ok := SimplePanelSessionCheck(w, r, &user) _, ok := SimplePanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -1038,7 +1038,7 @@ func route_panel_plugins_deactivate(w http.ResponseWriter, r *http.Request, user
} }
func route_panel_plugins_install(w http.ResponseWriter, r *http.Request, user User, uname string) { func route_panel_plugins_install(w http.ResponseWriter, r *http.Request, user User, uname string) {
_, ok := SimplePanelSessionCheck(w, r, &user) _, ok := SimplePanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -1124,7 +1124,7 @@ func route_panel_plugins_install(w http.ResponseWriter, r *http.Request, user Us
} }
func route_panel_users(w http.ResponseWriter, r *http.Request, user User) { func route_panel_users(w http.ResponseWriter, r *http.Request, user User) {
headerVars, stats, ok := PanelSessionCheck(w, r, &user) headerVars, stats, ok := PanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -1186,7 +1186,7 @@ func route_panel_users(w http.ResponseWriter, r *http.Request, user User) {
} }
func route_panel_users_edit(w http.ResponseWriter, r *http.Request, user User, suid string) { func route_panel_users_edit(w http.ResponseWriter, r *http.Request, user User, suid string) {
headerVars, stats, ok := PanelSessionCheck(w, r, &user) headerVars, stats, ok := PanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -1240,7 +1240,7 @@ func route_panel_users_edit(w http.ResponseWriter, r *http.Request, user User, s
} }
func route_panel_users_edit_submit(w http.ResponseWriter, r *http.Request, user User, suid string) { func route_panel_users_edit_submit(w http.ResponseWriter, r *http.Request, user User, suid string) {
_, ok := SimplePanelSessionCheck(w, r, &user) _, ok := SimplePanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -1335,7 +1335,7 @@ func route_panel_users_edit_submit(w http.ResponseWriter, r *http.Request, user
} }
func route_panel_groups(w http.ResponseWriter, r *http.Request, user User) { func route_panel_groups(w http.ResponseWriter, r *http.Request, user User) {
headerVars, stats, ok := PanelSessionCheck(w, r, &user) headerVars, stats, ok := PanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -1397,7 +1397,7 @@ func route_panel_groups(w http.ResponseWriter, r *http.Request, user User) {
} }
func route_panel_groups_edit(w http.ResponseWriter, r *http.Request, user User, sgid string) { func route_panel_groups_edit(w http.ResponseWriter, r *http.Request, user User, sgid string) {
headerVars, stats, ok := PanelSessionCheck(w, r, &user) headerVars, stats, ok := PanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -1456,7 +1456,7 @@ func route_panel_groups_edit(w http.ResponseWriter, r *http.Request, user User,
} }
func route_panel_groups_edit_perms(w http.ResponseWriter, r *http.Request, user User, sgid string) { func route_panel_groups_edit_perms(w http.ResponseWriter, r *http.Request, user User, sgid string) {
headerVars, stats, ok := PanelSessionCheck(w, r, &user) headerVars, stats, ok := PanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -1535,7 +1535,7 @@ func route_panel_groups_edit_perms(w http.ResponseWriter, r *http.Request, user
} }
func route_panel_groups_edit_submit(w http.ResponseWriter, r *http.Request, user User, sgid string) { func route_panel_groups_edit_submit(w http.ResponseWriter, r *http.Request, user User, sgid string) {
_, ok := SimplePanelSessionCheck(w, r, &user) _, ok := SimplePanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -1667,7 +1667,7 @@ func route_panel_groups_edit_submit(w http.ResponseWriter, r *http.Request, user
} }
func route_panel_groups_edit_perms_submit(w http.ResponseWriter, r *http.Request, user User, sgid string) { func route_panel_groups_edit_perms_submit(w http.ResponseWriter, r *http.Request, user User, sgid string) {
_, ok := SimplePanelSessionCheck(w, r, &user) _, ok := SimplePanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -1743,7 +1743,7 @@ func route_panel_groups_edit_perms_submit(w http.ResponseWriter, r *http.Request
} }
func route_panel_groups_create_submit(w http.ResponseWriter, r *http.Request, user User) { func route_panel_groups_create_submit(w http.ResponseWriter, r *http.Request, user User) {
_, ok := SimplePanelSessionCheck(w, r, &user) _, ok := SimplePanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -1793,7 +1793,7 @@ func route_panel_groups_create_submit(w http.ResponseWriter, r *http.Request, us
} }
func route_panel_themes(w http.ResponseWriter, r *http.Request, user User) { func route_panel_themes(w http.ResponseWriter, r *http.Request, user User) {
headerVars, stats, ok := PanelSessionCheck(w, r, &user) headerVars, stats, ok := PanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -1828,7 +1828,7 @@ func route_panel_themes(w http.ResponseWriter, r *http.Request, user User) {
} }
func route_panel_themes_set_default(w http.ResponseWriter, r *http.Request, user User, uname string) { func route_panel_themes_set_default(w http.ResponseWriter, r *http.Request, user User, uname string) {
_, ok := SimplePanelSessionCheck(w, r, &user) _, ok := SimplePanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -1909,7 +1909,7 @@ func route_panel_themes_set_default(w http.ResponseWriter, r *http.Request, user
} }
func route_panel_logs_mod(w http.ResponseWriter, r *http.Request, user User) { func route_panel_logs_mod(w http.ResponseWriter, r *http.Request, user User) {
headerVars, stats, ok := PanelSessionCheck(w, r, &user) headerVars, stats, ok := PanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -2025,7 +2025,7 @@ func route_panel_logs_mod(w http.ResponseWriter, r *http.Request, user User) {
} }
func route_panel_debug(w http.ResponseWriter, r *http.Request, user User) { func route_panel_debug(w http.ResponseWriter, r *http.Request, user User) {
headerVars, stats, ok := PanelSessionCheck(w, r, &user) headerVars, stats, ok := PanelUserCheck(w, r, &user)
if !ok { if !ok {
return return
} }

View File

@ -282,7 +282,7 @@ func socialgroupsGroupWidgets(headerVars *HeaderVars, sgItem *SocialGroup) (succ
*/ */
func socialgroupsGroupList(w http.ResponseWriter, r *http.Request, user User) { func socialgroupsGroupList(w http.ResponseWriter, r *http.Request, user User) {
headerVars, ok := SessionCheck(w, r, &user) headerVars, ok := UserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -352,7 +352,7 @@ func socialgroupsViewGroup(w http.ResponseWriter, r *http.Request, user User) {
} }
func socialgroupsCreateGroup(w http.ResponseWriter, r *http.Request, user User) { func socialgroupsCreateGroup(w http.ResponseWriter, r *http.Request, user User) {
headerVars, ok := SessionCheck(w, r, &user) headerVars, ok := UserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -429,7 +429,7 @@ func socialgroupsCreateGroupSubmit(w http.ResponseWriter, r *http.Request, user
} }
func socialgroupsMemberList(w http.ResponseWriter, r *http.Request, user User) { func socialgroupsMemberList(w http.ResponseWriter, r *http.Request, user User) {
headerVars, ok := SessionCheck(w, r, &user) headerVars, ok := UserCheck(w, r, &user)
if !ok { if !ok {
return return
} }

View File

@ -104,7 +104,7 @@ Disallow: /accounts/
} }
func route_overview(w http.ResponseWriter, r *http.Request, user User) { func route_overview(w http.ResponseWriter, r *http.Request, user User) {
headerVars, ok := SessionCheck(w, r, &user) headerVars, ok := UserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -124,7 +124,7 @@ func route_overview(w http.ResponseWriter, r *http.Request, user User) {
} }
func route_custom_page(w http.ResponseWriter, r *http.Request, user User) { func route_custom_page(w http.ResponseWriter, r *http.Request, user User) {
headerVars, ok := SessionCheck(w, r, &user) headerVars, ok := UserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -151,7 +151,7 @@ func route_custom_page(w http.ResponseWriter, r *http.Request, user User) {
// TODO: Paginate this // TODO: Paginate this
func route_topics(w http.ResponseWriter, r *http.Request, user User) { func route_topics(w http.ResponseWriter, r *http.Request, user User) {
headerVars, ok := SessionCheck(w, r, &user) headerVars, ok := UserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -270,7 +270,7 @@ func route_forum(w http.ResponseWriter, r *http.Request, user User, sfid string)
return return
} }
headerVars, ok := ForumSessionCheck(w, r, &user, fid) headerVars, ok := ForumUserCheck(w, r, &user, fid)
if !ok { if !ok {
return return
} }
@ -372,7 +372,7 @@ func route_forum(w http.ResponseWriter, r *http.Request, user User, sfid string)
} }
func route_forums(w http.ResponseWriter, r *http.Request, user User) { func route_forums(w http.ResponseWriter, r *http.Request, user User) {
headerVars, ok := SessionCheck(w, r, &user) headerVars, ok := UserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -453,7 +453,7 @@ func route_topic_id(w http.ResponseWriter, r *http.Request, user User) {
} }
topic.ClassName = "" topic.ClassName = ""
headerVars, ok := ForumSessionCheck(w, r, &user, topic.ParentID) headerVars, ok := ForumUserCheck(w, r, &user, topic.ParentID)
if !ok { if !ok {
return return
} }
@ -605,7 +605,7 @@ func route_topic_id(w http.ResponseWriter, r *http.Request, user User) {
} }
func route_profile(w http.ResponseWriter, r *http.Request, user User) { func route_profile(w http.ResponseWriter, r *http.Request, user User) {
headerVars, ok := SessionCheck(w, r, &user) headerVars, ok := UserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -714,7 +714,7 @@ func route_topic_create(w http.ResponseWriter, r *http.Request, user User, sfid
} }
} }
headerVars, ok := ForumSessionCheck(w, r, &user, fid) headerVars, ok := ForumUserCheck(w, r, &user, fid)
if !ok { if !ok {
return return
} }
@ -790,7 +790,7 @@ func route_topic_create_submit(w http.ResponseWriter, r *http.Request, user User
} }
// TODO: Add hooks to make use of headerLite // TODO: Add hooks to make use of headerLite
_, ok := SimpleForumSessionCheck(w, r, &user, fid) _, ok := SimpleForumUserCheck(w, r, &user, fid)
if !ok { if !ok {
return return
} }
@ -866,7 +866,7 @@ func route_create_reply(w http.ResponseWriter, r *http.Request, user User) {
} }
// TODO: Add hooks to make use of headerLite // TODO: Add hooks to make use of headerLite
_, ok := SimpleForumSessionCheck(w, r, &user, topic.ParentID) _, ok := SimpleForumUserCheck(w, r, &user, topic.ParentID)
if !ok { if !ok {
return return
} }
@ -963,7 +963,7 @@ func route_like_topic(w http.ResponseWriter, r *http.Request, user User) {
} }
// TODO: Add hooks to make use of headerLite // TODO: Add hooks to make use of headerLite
_, ok := SimpleForumSessionCheck(w, r, &user, topic.ParentID) _, ok := SimpleForumUserCheck(w, r, &user, topic.ParentID)
if !ok { if !ok {
return return
} }
@ -1074,7 +1074,7 @@ func route_reply_like_submit(w http.ResponseWriter, r *http.Request, user User)
} }
// TODO: Add hooks to make use of headerLite // TODO: Add hooks to make use of headerLite
_, ok := SimpleForumSessionCheck(w, r, &user, fid) _, ok := SimpleForumUserCheck(w, r, &user, fid)
if !ok { if !ok {
return return
} }
@ -1322,7 +1322,7 @@ func route_report_submit(w http.ResponseWriter, r *http.Request, user User, site
} }
func route_account_own_edit_critical(w http.ResponseWriter, r *http.Request, user User) { func route_account_own_edit_critical(w http.ResponseWriter, r *http.Request, user User) {
headerVars, ok := SessionCheck(w, r, &user) headerVars, ok := UserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -1341,7 +1341,7 @@ func route_account_own_edit_critical(w http.ResponseWriter, r *http.Request, use
} }
func route_account_own_edit_critical_submit(w http.ResponseWriter, r *http.Request, user User) { func route_account_own_edit_critical_submit(w http.ResponseWriter, r *http.Request, user User) {
headerVars, ok := SessionCheck(w, r, &user) headerVars, ok := UserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -1398,7 +1398,7 @@ func route_account_own_edit_critical_submit(w http.ResponseWriter, r *http.Reque
} }
func route_account_own_edit_avatar(w http.ResponseWriter, r *http.Request, user User) { func route_account_own_edit_avatar(w http.ResponseWriter, r *http.Request, user User) {
headerVars, ok := SessionCheck(w, r, &user) headerVars, ok := UserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -1422,7 +1422,7 @@ func route_account_own_edit_avatar_submit(w http.ResponseWriter, r *http.Request
} }
r.Body = http.MaxBytesReader(w, r.Body, int64(config.MaxRequestSize)) r.Body = http.MaxBytesReader(w, r.Body, int64(config.MaxRequestSize))
headerVars, ok := SessionCheck(w, r, &user) headerVars, ok := UserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -1514,7 +1514,7 @@ func route_account_own_edit_avatar_submit(w http.ResponseWriter, r *http.Request
} }
func route_account_own_edit_username(w http.ResponseWriter, r *http.Request, user User) { func route_account_own_edit_username(w http.ResponseWriter, r *http.Request, user User) {
headerVars, ok := SessionCheck(w, r, &user) headerVars, ok := UserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -1532,7 +1532,7 @@ func route_account_own_edit_username(w http.ResponseWriter, r *http.Request, use
} }
func route_account_own_edit_username_submit(w http.ResponseWriter, r *http.Request, user User) { func route_account_own_edit_username_submit(w http.ResponseWriter, r *http.Request, user User) {
headerVars, ok := SessionCheck(w, r, &user) headerVars, ok := UserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -1572,7 +1572,7 @@ func route_account_own_edit_username_submit(w http.ResponseWriter, r *http.Reque
} }
func route_account_own_edit_email(w http.ResponseWriter, r *http.Request, user User) { func route_account_own_edit_email(w http.ResponseWriter, r *http.Request, user User) {
headerVars, ok := SessionCheck(w, r, &user) headerVars, ok := UserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -1627,7 +1627,7 @@ func route_account_own_edit_email(w http.ResponseWriter, r *http.Request, user U
} }
func route_account_own_edit_email_token_submit(w http.ResponseWriter, r *http.Request, user User) { func route_account_own_edit_email_token_submit(w http.ResponseWriter, r *http.Request, user User) {
headerVars, ok := SessionCheck(w, r, &user) headerVars, ok := UserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -1716,7 +1716,7 @@ func route_logout(w http.ResponseWriter, r *http.Request, user User) {
} }
func route_login(w http.ResponseWriter, r *http.Request, user User) { func route_login(w http.ResponseWriter, r *http.Request, user User) {
headerVars, ok := SessionCheck(w, r, &user) headerVars, ok := UserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -1785,7 +1785,7 @@ func route_login_submit(w http.ResponseWriter, r *http.Request, user User) {
} }
func route_register(w http.ResponseWriter, r *http.Request, user User) { func route_register(w http.ResponseWriter, r *http.Request, user User) {
headerVars, ok := SessionCheck(w, r, &user) headerVars, ok := UserCheck(w, r, &user)
if !ok { if !ok {
return return
} }
@ -1803,7 +1803,7 @@ func route_register(w http.ResponseWriter, r *http.Request, user User) {
} }
func route_register_submit(w http.ResponseWriter, r *http.Request, user User) { func route_register_submit(w http.ResponseWriter, r *http.Request, user User) {
headerLite, _ := SimpleSessionCheck(w, r, &user) headerLite, _ := SimpleUserCheck(w, r, &user)
err := r.ParseForm() err := r.ParseForm()
if err != nil { if err != nil {
@ -1902,7 +1902,7 @@ func route_register_submit(w http.ResponseWriter, r *http.Request, user User) {
// TODO: Set the cookie domain // TODO: Set the cookie domain
func route_change_theme(w http.ResponseWriter, r *http.Request, user User) { func route_change_theme(w http.ResponseWriter, r *http.Request, user User) {
//headerLite, _ := SimpleSessionCheck(w, r, &user) //headerLite, _ := SimpleUserCheck(w, r, &user)
err := r.ParseForm() err := r.ParseForm()
if err != nil { if err != nil {
PreError("Bad Form", w, r) PreError("Bad Form", w, r)

View File

@ -11,14 +11,13 @@ import (
// nolint // nolint
var PreRoute func(http.ResponseWriter, *http.Request) (User, bool) = preRoute var PreRoute func(http.ResponseWriter, *http.Request) (User, bool) = preRoute
// TODO: Are these even session checks anymore? We might need to rethink these names
// nolint We need these types so people can tell what they are without scrolling to the bottom of the file // nolint We need these types so people can tell what they are without scrolling to the bottom of the file
var PanelSessionCheck func(http.ResponseWriter, *http.Request, *User) (*HeaderVars, PanelStats, bool) = _panel_session_check var PanelUserCheck func(http.ResponseWriter, *http.Request, *User) (*HeaderVars, PanelStats, bool) = panelUserCheck
var SimplePanelSessionCheck func(http.ResponseWriter, *http.Request, *User) (*HeaderLite, bool) = _simple_panel_session_check var SimplePanelUserCheck func(http.ResponseWriter, *http.Request, *User) (*HeaderLite, bool) = simplePanelUserCheck
var SimpleForumSessionCheck func(w http.ResponseWriter, r *http.Request, user *User, fid int) (headerLite *HeaderLite, success bool) = _simple_forum_session_check var SimpleForumUserCheck func(w http.ResponseWriter, r *http.Request, user *User, fid int) (headerLite *HeaderLite, success bool) = simpleForumUserCheck
var ForumSessionCheck func(w http.ResponseWriter, r *http.Request, user *User, fid int) (headerVars *HeaderVars, success bool) = _forum_session_check var ForumUserCheck func(w http.ResponseWriter, r *http.Request, user *User, fid int) (headerVars *HeaderVars, success bool) = forumUserCheck
var SimpleSessionCheck func(w http.ResponseWriter, r *http.Request, user *User) (headerLite *HeaderLite, success bool) = _simple_session_check var SimpleUserCheck func(w http.ResponseWriter, r *http.Request, user *User) (headerLite *HeaderLite, success bool) = simpleUserCheck
var SessionCheck func(w http.ResponseWriter, r *http.Request, user *User) (headerVars *HeaderVars, success bool) = _session_check var UserCheck func(w http.ResponseWriter, r *http.Request, user *User) (headerVars *HeaderVars, success bool) = userCheck
// TODO: Support for left sidebars and sidebars on both sides // TODO: Support for left sidebars and sidebars on both sides
// http.Request is for context.Context middleware. Mostly for plugin_socialgroups right now // http.Request is for context.Context middleware. Mostly for plugin_socialgroups right now
@ -45,7 +44,7 @@ func BuildWidgets(zone string, data interface{}, headerVars *HeaderVars, r *http
} }
} }
func _simple_forum_session_check(w http.ResponseWriter, r *http.Request, user *User, fid int) (headerLite *HeaderLite, success bool) { func simpleForumUserCheck(w http.ResponseWriter, r *http.Request, user *User, fid int) (headerLite *HeaderLite, success bool) {
if !fstore.Exists(fid) { if !fstore.Exists(fid) {
PreError("The target forum doesn't exist.", w, r) PreError("The target forum doesn't exist.", w, r)
return nil, false return nil, false
@ -81,8 +80,8 @@ func _simple_forum_session_check(w http.ResponseWriter, r *http.Request, user *U
return headerLite, true return headerLite, true
} }
func _forum_session_check(w http.ResponseWriter, r *http.Request, user *User, fid int) (headerVars *HeaderVars, success bool) { func forumUserCheck(w http.ResponseWriter, r *http.Request, user *User, fid int) (headerVars *HeaderVars, success bool) {
headerVars, success = SessionCheck(w, r, user) headerVars, success = UserCheck(w, r, user)
if !fstore.Exists(fid) { if !fstore.Exists(fid) {
NotFound(w, r) NotFound(w, r)
return headerVars, false return headerVars, false
@ -120,7 +119,7 @@ func _forum_session_check(w http.ResponseWriter, r *http.Request, user *User, fi
// Even if they have the right permissions, the control panel is only open to supermods+. There are many areas without subpermissions which assume that the current user is a supermod+ and admins are extremely unlikely to give these permissions to someone who isn't at-least a supermod to begin with // Even if they have the right permissions, the control panel is only open to supermods+. There are many areas without subpermissions which assume that the current user is a supermod+ and admins are extremely unlikely to give these permissions to someone who isn't at-least a supermod to begin with
// TODO: Do a panel specific theme? // TODO: Do a panel specific theme?
func _panel_session_check(w http.ResponseWriter, r *http.Request, user *User) (headerVars *HeaderVars, stats PanelStats, success bool) { func panelUserCheck(w http.ResponseWriter, r *http.Request, user *User) (headerVars *HeaderVars, stats PanelStats, success bool) {
var themeName = defaultThemeBox.Load().(string) var themeName = defaultThemeBox.Load().(string)
cookie, err := r.Cookie("current_theme") cookie, err := r.Cookie("current_theme")
@ -190,7 +189,7 @@ func _panel_session_check(w http.ResponseWriter, r *http.Request, user *User) (h
return headerVars, stats, true return headerVars, stats, true
} }
func _simple_panel_session_check(w http.ResponseWriter, r *http.Request, user *User) (headerLite *HeaderLite, success bool) { func simplePanelUserCheck(w http.ResponseWriter, r *http.Request, user *User) (headerLite *HeaderLite, success bool) {
if !user.IsSuperMod { if !user.IsSuperMod {
NoPermissions(w, r, *user) NoPermissions(w, r, *user)
return headerLite, false return headerLite, false
@ -202,8 +201,8 @@ func _simple_panel_session_check(w http.ResponseWriter, r *http.Request, user *U
return headerLite, true return headerLite, true
} }
// SimpleSessionCheck is back from the grave, yay :D // SimpleUserCheck is back from the grave, yay :D
func _simple_session_check(w http.ResponseWriter, r *http.Request, user *User) (headerLite *HeaderLite, success bool) { func simpleUserCheck(w http.ResponseWriter, r *http.Request, user *User) (headerLite *HeaderLite, success bool) {
headerLite = &HeaderLite{ headerLite = &HeaderLite{
Site: site, Site: site,
Settings: settingBox.Load().(SettingBox), Settings: settingBox.Load().(SettingBox),
@ -212,7 +211,7 @@ func _simple_session_check(w http.ResponseWriter, r *http.Request, user *User) (
} }
// TODO: Add the ability for admins to restrict certain themes to certain groups? // TODO: Add the ability for admins to restrict certain themes to certain groups?
func _session_check(w http.ResponseWriter, r *http.Request, user *User) (headerVars *HeaderVars, success bool) { func userCheck(w http.ResponseWriter, r *http.Request, user *User) (headerVars *HeaderVars, success bool) {
var themeName = defaultThemeBox.Load().(string) var themeName = defaultThemeBox.Load().(string)
cookie, err := r.Cookie("current_theme") cookie, err := r.Cookie("current_theme")