Deleted utils.GetUser

This commit is contained in:
2019-11-17 16:59:34 +09:00
parent ad9870b1c1
commit daed4146ed
117 changed files with 178 additions and 271 deletions

View File

@ -7,12 +7,11 @@ import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
// Get ...
func Get(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil || (user.Role != "admin" && user.Role != "editor") {
return ctx.Redirect(http.StatusTemporaryRedirect, "/")

View File

@ -7,14 +7,13 @@ import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
const maxAnimeEntries = 70
// editorList renders the anime list with the given title and filter.
func editorList(ctx aero.Context, title string, filter func(*arn.Anime) bool, searchLink func(*arn.Anime) string) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil || (user.Role != "admin" && user.Role != "editor") {
return ctx.Error(http.StatusUnauthorized, "Not authorized")

View File

@ -6,14 +6,13 @@ import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
const maxEntries = 70
// NoDescription ...
func NoDescription(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil || (user.Role != "admin" && user.Role != "editor") {
return ctx.Redirect(http.StatusTemporaryRedirect, "/")

View File

@ -7,14 +7,13 @@ import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
const maxSoundTrackEntries = 70
// editorList renders the soundtrack list with the given title and filter.
func editorList(ctx aero.Context, title string, filter func(*arn.SoundTrack) bool, searchLink func(*arn.SoundTrack) string) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil || (user.Role != "admin" && user.Role != "editor") {
return ctx.Error(http.StatusUnauthorized, "Not authorized")

View File

@ -4,6 +4,7 @@ import (
"sort"
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
@ -30,7 +31,7 @@ var jobLogs = []string{}
// Overview shows all background jobs.
func Overview(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
jobs := []*utils.JobInfo{}
for _, job := range jobInfo {

View File

@ -7,7 +7,6 @@ import (
"github.com/animenotifier/notify.moe/arn"
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/utils"
)
// Only allow one job to be started at a time
@ -18,7 +17,7 @@ func Start(ctx aero.Context) error {
jobStartMutex.Lock()
defer jobStartMutex.Unlock()
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil || (user.Role != "editor" && user.Role != "admin") {
return ctx.Error(http.StatusUnauthorized, "Not authorized")

View File

@ -7,12 +7,11 @@ import (
"github.com/animenotifier/kitsu"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
// NewKitsuAnime ...
func NewKitsuAnime(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
finder := arn.NewAnimeFinder("kitsu/anime")
deletedIDs, err := arn.GetIDList("deleted kitsu anime")

View File

@ -19,7 +19,7 @@ type diffFunction func(*arn.Anime, *mal.Anime) []animediff.Difference
// CompareMAL ...
func CompareMAL(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
year := ctx.Get("year")
status := ctx.Get("status")
season := ctx.Get("season")