Improved error logging
This commit is contained in:
parent
bf544836fa
commit
e46c9b1586
@ -57,24 +57,28 @@ func logRequest(ctx *aero.Context, responseTime time.Duration) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Log every request
|
// Log every request
|
||||||
|
id := "[id]"
|
||||||
|
nick := "[guest]"
|
||||||
|
|
||||||
if user != nil {
|
if user != nil {
|
||||||
request.Info(user.Nick, ip, hostName, responseTimeString, ctx.StatusCode, ctx.URI())
|
id = user.ID
|
||||||
} else {
|
nick = user.Nick
|
||||||
request.Info("[guest]", ip, hostName, responseTimeString, ctx.StatusCode, ctx.URI())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
request.Info(nick, id, ip, hostName, responseTimeString, ctx.StatusCode, ctx.URI())
|
||||||
|
|
||||||
// Log all requests that failed
|
// Log all requests that failed
|
||||||
switch ctx.StatusCode {
|
switch ctx.StatusCode {
|
||||||
case http.StatusOK, http.StatusFound, http.StatusMovedPermanently, http.StatusPermanentRedirect, http.StatusTemporaryRedirect:
|
case http.StatusOK, http.StatusFound, http.StatusMovedPermanently, http.StatusPermanentRedirect, http.StatusTemporaryRedirect:
|
||||||
// Ok.
|
// Ok.
|
||||||
|
|
||||||
default:
|
default:
|
||||||
err.Error(http.StatusText(ctx.StatusCode), ip, hostName, responseTimeString, ctx.StatusCode, ctx.URI())
|
err.Error(nick, id, ip, hostName, responseTimeString, ctx.StatusCode, ctx.URI(), ctx.ErrorMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notify us about long requests.
|
// Notify us about long requests.
|
||||||
// However ignore requests under /auth/ because those depend on 3rd party servers.
|
// However ignore requests under /auth/ because those depend on 3rd party servers.
|
||||||
if responseTime >= 300*time.Millisecond && !strings.HasPrefix(ctx.URI(), "/auth/") && !strings.HasPrefix(ctx.URI(), "/sitemap/") {
|
if responseTime >= 300*time.Millisecond && !strings.HasPrefix(ctx.URI(), "/auth/") && !strings.HasPrefix(ctx.URI(), "/sitemap/") {
|
||||||
err.Error("Long response time", ip, hostName, responseTimeString, ctx.StatusCode, ctx.URI())
|
err.Error("Long response time", nick, id, ip, hostName, responseTimeString, ctx.StatusCode, ctx.URI())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,11 +15,11 @@ func PurchaseHistory(ctx *aero.Context) string {
|
|||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not logged in", nil)
|
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
||||||
}
|
}
|
||||||
|
|
||||||
if user.Role != "admin" {
|
if user.Role != "admin" {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not authorized", nil)
|
return ctx.Error(http.StatusUnauthorized, "Not authorized")
|
||||||
}
|
}
|
||||||
|
|
||||||
purchases, err := arn.AllPurchases()
|
purchases, err := arn.AllPurchases()
|
||||||
|
@ -16,11 +16,11 @@ func UserRegistrations(ctx *aero.Context) string {
|
|||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not logged in", nil)
|
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
||||||
}
|
}
|
||||||
|
|
||||||
if user.Role != "admin" {
|
if user.Role != "admin" {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not authorized", nil)
|
return ctx.Error(http.StatusUnauthorized, "Not authorized")
|
||||||
}
|
}
|
||||||
|
|
||||||
total := 0
|
total := 0
|
||||||
|
@ -16,7 +16,7 @@ func Main(ctx *aero.Context) string {
|
|||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not logged in or not auhorized to edit this anime", nil)
|
return ctx.Error(http.StatusUnauthorized, "Not logged in or not auhorized to edit this anime")
|
||||||
}
|
}
|
||||||
|
|
||||||
anime, err := arn.GetAnime(id)
|
anime, err := arn.GetAnime(id)
|
||||||
@ -34,7 +34,7 @@ func Images(ctx *aero.Context) string {
|
|||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not logged in or not auhorized to edit this anime", nil)
|
return ctx.Error(http.StatusUnauthorized, "Not logged in or not auhorized to edit this anime")
|
||||||
}
|
}
|
||||||
|
|
||||||
anime, err := arn.GetAnime(id)
|
anime, err := arn.GetAnime(id)
|
||||||
@ -52,7 +52,7 @@ func Characters(ctx *aero.Context) string {
|
|||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not logged in or not auhorized to edit", nil)
|
return ctx.Error(http.StatusUnauthorized, "Not logged in or not auhorized to edit")
|
||||||
}
|
}
|
||||||
|
|
||||||
anime, err := arn.GetAnime(id)
|
anime, err := arn.GetAnime(id)
|
||||||
@ -76,7 +76,7 @@ func Relations(ctx *aero.Context) string {
|
|||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not logged in or not auhorized to edit", nil)
|
return ctx.Error(http.StatusUnauthorized, "Not logged in or not auhorized to edit")
|
||||||
}
|
}
|
||||||
|
|
||||||
anime, err := arn.GetAnime(id)
|
anime, err := arn.GetAnime(id)
|
||||||
@ -100,7 +100,7 @@ func Episodes(ctx *aero.Context) string {
|
|||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not logged in or not auhorized to edit", nil)
|
return ctx.Error(http.StatusUnauthorized, "Not logged in or not auhorized to edit")
|
||||||
}
|
}
|
||||||
|
|
||||||
anime, err := arn.GetAnime(id)
|
anime, err := arn.GetAnime(id)
|
||||||
|
@ -16,7 +16,7 @@ func RedirectByMapping(mappingName string) func(*aero.Context) string {
|
|||||||
anime := finder.GetAnime(id)
|
anime := finder.GetAnime(id)
|
||||||
|
|
||||||
if anime == nil {
|
if anime == nil {
|
||||||
return ctx.Error(http.StatusNotFound, "Anime not found", nil)
|
return ctx.Error(http.StatusNotFound, "Anime not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
return utils.SmartRedirect(ctx, "/anime/"+anime.ID)
|
return utils.SmartRedirect(ctx, "/anime/"+anime.ID)
|
||||||
|
@ -17,7 +17,7 @@ func DeleteKitsu(ctx *aero.Context) string {
|
|||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not authorized", nil)
|
return ctx.Error(http.StatusUnauthorized, "Not authorized")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that the anime really exists
|
// Check that the anime really exists
|
||||||
|
@ -19,7 +19,7 @@ func Kitsu(ctx *aero.Context) string {
|
|||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not authorized", nil)
|
return ctx.Error(http.StatusUnauthorized, "Not authorized")
|
||||||
}
|
}
|
||||||
|
|
||||||
kitsuAnimeObj, err := arn.Kitsu.Get("Anime", id)
|
kitsuAnimeObj, err := arn.Kitsu.Get("Anime", id)
|
||||||
|
@ -38,7 +38,7 @@ func AnimeList(ctx *aero.Context, user *arn.User, status string) string {
|
|||||||
animeList := viewUser.AnimeList()
|
animeList := viewUser.AnimeList()
|
||||||
|
|
||||||
if animeList == nil {
|
if animeList == nil {
|
||||||
return ctx.Error(http.StatusNotFound, "Anime list not found", nil)
|
return ctx.Error(http.StatusNotFound, "Anime list not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
statusList := animeList.FilterStatus(status)
|
statusList := animeList.FilterStatus(status)
|
||||||
|
@ -12,7 +12,7 @@ func Redirect(ctx *aero.Context) string {
|
|||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not logged in", nil)
|
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
||||||
}
|
}
|
||||||
|
|
||||||
return ctx.Redirect("/+" + user.Nick + ctx.URI())
|
return ctx.Redirect("/+" + user.Nick + ctx.URI())
|
||||||
|
@ -14,7 +14,7 @@ func Get(ctx *aero.Context) string {
|
|||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not logged in", nil)
|
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
||||||
}
|
}
|
||||||
|
|
||||||
return ctx.HTML(components.Charge(user))
|
return ctx.HTML(components.Charge(user))
|
||||||
|
@ -26,7 +26,7 @@ package dashboard
|
|||||||
// user := utils.GetUser(ctx)
|
// user := utils.GetUser(ctx)
|
||||||
|
|
||||||
// if user == nil {
|
// if user == nil {
|
||||||
// return ctx.Error(http.StatusUnauthorized, "Not logged in", nil)
|
// return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// flow.Parallel(func() {
|
// flow.Parallel(func() {
|
||||||
|
@ -24,7 +24,7 @@ func Get(ctx *aero.Context) string {
|
|||||||
nick := ctx.Get("nick")
|
nick := ctx.Get("nick")
|
||||||
|
|
||||||
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not authorized", nil)
|
return ctx.Error(http.StatusUnauthorized, "Not authorized")
|
||||||
}
|
}
|
||||||
|
|
||||||
viewUser, err := arn.GetUserByNick(nick)
|
viewUser, err := arn.GetUserByNick(nick)
|
||||||
|
@ -17,7 +17,7 @@ func editorList(ctx *aero.Context, title string, filter func(*arn.Anime) bool, s
|
|||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
if user == nil || (user.Role != "admin" && user.Role != "editor") {
|
if user == nil || (user.Role != "admin" && user.Role != "editor") {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not authorized", nil)
|
return ctx.Error(http.StatusUnauthorized, "Not authorized")
|
||||||
}
|
}
|
||||||
|
|
||||||
animes, count := filterAnime(ctx, user, filter)
|
animes, count := filterAnime(ctx, user, filter)
|
||||||
|
@ -17,7 +17,7 @@ func editorList(ctx *aero.Context, title string, filter func(*arn.SoundTrack) bo
|
|||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
if user == nil || (user.Role != "admin" && user.Role != "editor") {
|
if user == nil || (user.Role != "admin" && user.Role != "editor") {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not authorized", nil)
|
return ctx.Error(http.StatusUnauthorized, "Not authorized")
|
||||||
}
|
}
|
||||||
|
|
||||||
tracks, count := filterSoundTracks(ctx, user, filter)
|
tracks, count := filterSoundTracks(ctx, user, filter)
|
||||||
|
@ -21,18 +21,18 @@ func Start(ctx *aero.Context) string {
|
|||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not authorized", nil)
|
return ctx.Error(http.StatusUnauthorized, "Not authorized")
|
||||||
}
|
}
|
||||||
|
|
||||||
jobName := ctx.Get("job")
|
jobName := ctx.Get("job")
|
||||||
job := jobInfo[jobName]
|
job := jobInfo[jobName]
|
||||||
|
|
||||||
if job == nil {
|
if job == nil {
|
||||||
return ctx.Error(http.StatusBadRequest, "Job not available", nil)
|
return ctx.Error(http.StatusBadRequest, "Job not available")
|
||||||
}
|
}
|
||||||
|
|
||||||
if job.IsRunning() {
|
if job.IsRunning() {
|
||||||
return ctx.Error(http.StatusBadRequest, "Job is currently running!", nil)
|
return ctx.Error(http.StatusBadRequest, "Job is currently running!")
|
||||||
}
|
}
|
||||||
|
|
||||||
job.Start()
|
job.Start()
|
||||||
|
@ -25,7 +25,7 @@ func Get(ctx *aero.Context) string {
|
|||||||
animeList := user.AnimeList()
|
animeList := user.AnimeList()
|
||||||
|
|
||||||
if animeList == nil {
|
if animeList == nil {
|
||||||
return ctx.Error(http.StatusNotFound, "Anime list not found", nil)
|
return ctx.Error(http.StatusNotFound, "Anime list not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
watchingList := animeList.Watching()
|
watchingList := animeList.Watching()
|
||||||
|
@ -36,7 +36,7 @@ func Get(ctx *aero.Context) string {
|
|||||||
episode := animeEpisodes.Find(episodeNumber)
|
episode := animeEpisodes.Find(episodeNumber)
|
||||||
|
|
||||||
if episode == nil {
|
if episode == nil {
|
||||||
return ctx.Error(http.StatusNotFound, "Anime episode not found", nil)
|
return ctx.Error(http.StatusNotFound, "Anime episode not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
return ctx.HTML(components.AnimeEpisode(anime, episode, user))
|
return ctx.HTML(components.AnimeEpisode(anime, episode, user))
|
||||||
|
@ -16,7 +16,7 @@ func Sequels(ctx *aero.Context) string {
|
|||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not logged in", nil)
|
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
||||||
}
|
}
|
||||||
|
|
||||||
animeList := user.AnimeList()
|
animeList := user.AnimeList()
|
||||||
|
@ -17,7 +17,7 @@ func Get(ctx *aero.Context) string {
|
|||||||
viewUser := user
|
viewUser := user
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not logged in", nil)
|
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
||||||
}
|
}
|
||||||
|
|
||||||
inventory, err := arn.GetInventory(viewUser.ID)
|
inventory, err := arn.GetInventory(viewUser.ID)
|
||||||
|
@ -13,7 +13,7 @@ func Get(ctx *aero.Context) string {
|
|||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusBadRequest, "Not logged in", nil)
|
return ctx.Error(http.StatusBadRequest, "Not logged in")
|
||||||
}
|
}
|
||||||
|
|
||||||
return ctx.HTML(components.ImportLists(user))
|
return ctx.HTML(components.ImportLists(user))
|
||||||
|
@ -16,7 +16,7 @@ func Preview(ctx *aero.Context) string {
|
|||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusBadRequest, "Not logged in", nil)
|
return ctx.Error(http.StatusBadRequest, "Not logged in")
|
||||||
}
|
}
|
||||||
|
|
||||||
matches, response := getMatches(ctx)
|
matches, response := getMatches(ctx)
|
||||||
@ -33,7 +33,7 @@ func Finish(ctx *aero.Context) string {
|
|||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusBadRequest, "Not logged in", nil)
|
return ctx.Error(http.StatusBadRequest, "Not logged in")
|
||||||
}
|
}
|
||||||
|
|
||||||
matches, response := getMatches(ctx)
|
matches, response := getMatches(ctx)
|
||||||
@ -76,7 +76,7 @@ func getMatches(ctx *aero.Context) ([]*arn.AniListMatch, string) {
|
|||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return nil, ctx.Error(http.StatusBadRequest, "Not logged in", nil)
|
return nil, ctx.Error(http.StatusBadRequest, "Not logged in")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get user
|
// Get user
|
||||||
|
@ -15,7 +15,7 @@ func Preview(ctx *aero.Context) string {
|
|||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusBadRequest, "Not logged in", nil)
|
return ctx.Error(http.StatusBadRequest, "Not logged in")
|
||||||
}
|
}
|
||||||
|
|
||||||
matches, response := getMatches(ctx)
|
matches, response := getMatches(ctx)
|
||||||
@ -32,7 +32,7 @@ func Finish(ctx *aero.Context) string {
|
|||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusBadRequest, "Not logged in", nil)
|
return ctx.Error(http.StatusBadRequest, "Not logged in")
|
||||||
}
|
}
|
||||||
|
|
||||||
matches, response := getMatches(ctx)
|
matches, response := getMatches(ctx)
|
||||||
@ -87,7 +87,7 @@ func getMatches(ctx *aero.Context) ([]*arn.KitsuMatch, string) {
|
|||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return nil, ctx.Error(http.StatusBadRequest, "Not logged in", nil)
|
return nil, ctx.Error(http.StatusBadRequest, "Not logged in")
|
||||||
}
|
}
|
||||||
|
|
||||||
kitsuUser, err := kitsu.GetUser(user.Accounts.Kitsu.Nick)
|
kitsuUser, err := kitsu.GetUser(user.Accounts.Kitsu.Nick)
|
||||||
|
@ -16,7 +16,7 @@ func Preview(ctx *aero.Context) string {
|
|||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusBadRequest, "Not logged in", nil)
|
return ctx.Error(http.StatusBadRequest, "Not logged in")
|
||||||
}
|
}
|
||||||
|
|
||||||
matches, response := getMatches(ctx)
|
matches, response := getMatches(ctx)
|
||||||
@ -33,7 +33,7 @@ func Finish(ctx *aero.Context) string {
|
|||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusBadRequest, "Not logged in", nil)
|
return ctx.Error(http.StatusBadRequest, "Not logged in")
|
||||||
}
|
}
|
||||||
|
|
||||||
matches, response := getMatches(ctx)
|
matches, response := getMatches(ctx)
|
||||||
@ -83,7 +83,7 @@ func getMatches(ctx *aero.Context) ([]*arn.MyAnimeListMatch, string) {
|
|||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return nil, ctx.Error(http.StatusBadRequest, "Not logged in", nil)
|
return nil, ctx.Error(http.StatusBadRequest, "Not logged in")
|
||||||
}
|
}
|
||||||
|
|
||||||
malAnimeList, err := mal.GetAnimeList(user.Accounts.MyAnimeList.Nick)
|
malAnimeList, err := mal.GetAnimeList(user.Accounts.MyAnimeList.Nick)
|
||||||
|
@ -13,7 +13,7 @@ func Get(ctx *aero.Context) string {
|
|||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusBadRequest, "Not logged in", nil)
|
return ctx.Error(http.StatusBadRequest, "Not logged in")
|
||||||
}
|
}
|
||||||
|
|
||||||
return ctx.HTML(components.NewThread(user))
|
return ctx.HTML(components.NewThread(user))
|
||||||
|
@ -14,7 +14,7 @@ func CountUnseen(ctx *aero.Context) string {
|
|||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusBadRequest, "Not logged in", nil)
|
return ctx.Error(http.StatusBadRequest, "Not logged in")
|
||||||
}
|
}
|
||||||
|
|
||||||
unseen := user.Notifications().CountUnseen()
|
unseen := user.Notifications().CountUnseen()
|
||||||
@ -27,7 +27,7 @@ func MarkNotificationsAsSeen(ctx *aero.Context) string {
|
|||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusBadRequest, "Not logged in", nil)
|
return ctx.Error(http.StatusBadRequest, "Not logged in")
|
||||||
}
|
}
|
||||||
|
|
||||||
notifications := user.Notifications().Notifications()
|
notifications := user.Notifications().Notifications()
|
||||||
@ -45,7 +45,7 @@ func Test(ctx *aero.Context) string {
|
|||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusBadRequest, "Not logged in", nil)
|
return ctx.Error(http.StatusBadRequest, "Not logged in")
|
||||||
}
|
}
|
||||||
|
|
||||||
user.SendNotification(&arn.PushNotification{
|
user.SendNotification(&arn.PushNotification{
|
||||||
|
@ -18,7 +18,7 @@ func ByUser(ctx *aero.Context) string {
|
|||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusBadRequest, "Not logged in", nil)
|
return ctx.Error(http.StatusBadRequest, "Not logged in")
|
||||||
}
|
}
|
||||||
|
|
||||||
var viewUser *arn.User
|
var viewUser *arn.User
|
||||||
|
@ -15,7 +15,7 @@ func CreatePayment(ctx *aero.Context) string {
|
|||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not logged in", nil)
|
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify amount
|
// Verify amount
|
||||||
@ -29,7 +29,7 @@ func CreatePayment(ctx *aero.Context) string {
|
|||||||
case "1000", "2000", "3000", "6000", "12000", "25000", "50000", "75000":
|
case "1000", "2000", "3000", "6000", "12000", "25000", "50000", "75000":
|
||||||
// OK
|
// OK
|
||||||
default:
|
default:
|
||||||
return ctx.Error(http.StatusBadRequest, "Incorrect amount", nil)
|
return ctx.Error(http.StatusBadRequest, "Incorrect amount")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initiate PayPal client
|
// Initiate PayPal client
|
||||||
|
@ -20,7 +20,7 @@ func Success(ctx *aero.Context) string {
|
|||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not logged in", nil)
|
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
||||||
}
|
}
|
||||||
|
|
||||||
paymentID := ctx.Query("paymentId")
|
paymentID := ctx.Query("paymentId")
|
||||||
|
@ -16,7 +16,7 @@ func Get(ctx *aero.Context) string {
|
|||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not logged in or not auhorized to edit this post", nil)
|
return ctx.Error(http.StatusUnauthorized, "Not logged in or not auhorized to edit this post")
|
||||||
}
|
}
|
||||||
|
|
||||||
post, err := arn.GetPost(id)
|
post, err := arn.GetPost(id)
|
||||||
|
@ -14,7 +14,7 @@ func Get(component func(*arn.User) string) func(*aero.Context) string {
|
|||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not logged in", nil)
|
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
||||||
}
|
}
|
||||||
|
|
||||||
return ctx.HTML(component(user))
|
return ctx.HTML(component(user))
|
||||||
|
@ -21,7 +21,7 @@ func BuyItem(ctx *aero.Context) string {
|
|||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not logged in", nil)
|
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Item ID and quantity
|
// Item ID and quantity
|
||||||
@ -42,7 +42,7 @@ func BuyItem(ctx *aero.Context) string {
|
|||||||
totalPrice := int(item.Price) * quantity
|
totalPrice := int(item.Price) * quantity
|
||||||
|
|
||||||
if user.Balance < totalPrice {
|
if user.Balance < totalPrice {
|
||||||
return ctx.Error(http.StatusBadRequest, "Not enough gems. You need to charge up your balance before you can buy this item.", nil)
|
return ctx.Error(http.StatusBadRequest, "Not enough gems. You need to charge up your balance before you can buy this item.")
|
||||||
}
|
}
|
||||||
|
|
||||||
user.Balance -= totalPrice
|
user.Balance -= totalPrice
|
||||||
|
@ -15,7 +15,7 @@ func PurchaseHistory(ctx *aero.Context) string {
|
|||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not logged in", nil)
|
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
||||||
}
|
}
|
||||||
|
|
||||||
purchases, err := arn.FilterPurchases(func(purchase *arn.Purchase) bool {
|
purchases, err := arn.FilterPurchases(func(purchase *arn.Purchase) bool {
|
||||||
|
@ -16,7 +16,7 @@ func Get(ctx *aero.Context) string {
|
|||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not logged in", nil)
|
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
||||||
}
|
}
|
||||||
|
|
||||||
items, err := arn.AllShopItems()
|
items, err := arn.AllShopItems()
|
||||||
|
@ -16,7 +16,7 @@ func Get(ctx *aero.Context) string {
|
|||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not logged in or not auhorized to edit this thread", nil)
|
return ctx.Error(http.StatusUnauthorized, "Not logged in or not auhorized to edit this thread")
|
||||||
}
|
}
|
||||||
|
|
||||||
thread, err := arn.GetThread(id)
|
thread, err := arn.GetThread(id)
|
||||||
|
@ -15,7 +15,7 @@ func AMVFile(ctx *aero.Context) string {
|
|||||||
amvID := ctx.Get("id")
|
amvID := ctx.Get("id")
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not logged in", nil)
|
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
||||||
}
|
}
|
||||||
|
|
||||||
amv, err := arn.GetAMV(amvID)
|
amv, err := arn.GetAMV(amvID)
|
||||||
|
@ -15,7 +15,7 @@ func AnimeImage(ctx *aero.Context) string {
|
|||||||
animeID := ctx.Get("id")
|
animeID := ctx.Get("id")
|
||||||
|
|
||||||
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not authorized", nil)
|
return ctx.Error(http.StatusUnauthorized, "Not authorized")
|
||||||
}
|
}
|
||||||
|
|
||||||
anime, err := arn.GetAnime(animeID)
|
anime, err := arn.GetAnime(animeID)
|
||||||
|
@ -12,7 +12,7 @@ func Avatar(ctx *aero.Context) string {
|
|||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not logged in", nil)
|
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve file from post body
|
// Retrieve file from post body
|
||||||
|
@ -15,7 +15,7 @@ func CharacterImage(ctx *aero.Context) string {
|
|||||||
characterID := ctx.Get("id")
|
characterID := ctx.Get("id")
|
||||||
|
|
||||||
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not authorized", nil)
|
return ctx.Error(http.StatusUnauthorized, "Not authorized")
|
||||||
}
|
}
|
||||||
|
|
||||||
character, err := arn.GetCharacter(characterID)
|
character, err := arn.GetCharacter(characterID)
|
||||||
|
@ -12,11 +12,11 @@ func Cover(ctx *aero.Context) string {
|
|||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not logged in", nil)
|
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
||||||
}
|
}
|
||||||
|
|
||||||
if !user.IsPro() {
|
if !user.IsPro() {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Only available for PRO users", nil)
|
return ctx.Error(http.StatusUnauthorized, "Only available for PRO users")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve file from post body
|
// Retrieve file from post body
|
||||||
|
@ -15,7 +15,7 @@ func Edit(ctx *aero.Context) string {
|
|||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
if user == nil || user.Role != "admin" {
|
if user == nil || user.Role != "admin" {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not logged in or not auhorized to edit this user", nil)
|
return ctx.Error(http.StatusUnauthorized, "Not logged in or not auhorized to edit this user")
|
||||||
}
|
}
|
||||||
|
|
||||||
viewUser, err := arn.GetUserByNick(nick)
|
viewUser, err := arn.GetUserByNick(nick)
|
||||||
|
@ -13,11 +13,11 @@ func Get(ctx *aero.Context) string {
|
|||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusBadRequest, "Not logged in", nil)
|
return ctx.Error(http.StatusBadRequest, "Not logged in")
|
||||||
}
|
}
|
||||||
|
|
||||||
if user.Nick == "" {
|
if user.Nick == "" {
|
||||||
return ctx.Error(http.StatusInternalServerError, "User did not set a nickname", nil)
|
return ctx.Error(http.StatusInternalServerError, "User did not set a nickname")
|
||||||
}
|
}
|
||||||
|
|
||||||
return profile.Profile(ctx, user)
|
return profile.Profile(ctx, user)
|
||||||
|
Loading…
Reference in New Issue
Block a user