diff --git a/auth/auth.go b/auth/auth.go index 78470c98..a292b235 100644 --- a/auth/auth.go +++ b/auth/auth.go @@ -32,6 +32,6 @@ func Install(app *aero.Application) { ctx.Session().Delete("userId") } - return ctx.Redirect(http.StatusFound, "/") + return ctx.Redirect(http.StatusTemporaryRedirect, "/") }) } diff --git a/auth/facebook.go b/auth/facebook.go index 93ac1662..2e0b2f2d 100644 --- a/auth/facebook.go +++ b/auth/facebook.go @@ -48,7 +48,7 @@ func InstallFacebookAuth(app *aero.Application) { app.Get("/auth/facebook", func(ctx aero.Context) error { state := ctx.Session().ID() url := config.AuthCodeURL(state) - return ctx.Redirect(http.StatusFound, url) + return ctx.Redirect(http.StatusTemporaryRedirect, url) }) // This is the redirect URL that we specified in the OAuth2 config. @@ -111,7 +111,7 @@ func InstallFacebookAuth(app *aero.Application) { // Log authLog.Info("Added Facebook ID to existing account | %s | %s | %s | %s | %s", user.Nick, user.ID, ctx.IP(), user.Email, user.RealName()) - return ctx.Redirect(http.StatusFound, "/") + return ctx.Redirect(http.StatusTemporaryRedirect, "/") } var getErr error @@ -129,7 +129,7 @@ func InstallFacebookAuth(app *aero.Application) { user.Save() session.Set("userId", user.ID) - return ctx.Redirect(http.StatusFound, "/") + return ctx.Redirect(http.StatusTemporaryRedirect, "/") } // Try to find an existing user via the associated e-mail address @@ -142,7 +142,7 @@ func InstallFacebookAuth(app *aero.Application) { user.Save() session.Set("userId", user.ID) - return ctx.Redirect(http.StatusFound, "/") + return ctx.Redirect(http.StatusTemporaryRedirect, "/") } // Register new user @@ -173,6 +173,6 @@ func InstallFacebookAuth(app *aero.Application) { authLog.Info("Registered new user via Facebook | %s | %s | %s | %s | %s", user.Nick, user.ID, ctx.IP(), user.Email, user.RealName()) // Redirect to starting page for new users - return ctx.Redirect(http.StatusFound, newUserStartRoute) + return ctx.Redirect(http.StatusTemporaryRedirect, newUserStartRoute) }) } diff --git a/auth/google.go b/auth/google.go index d96f67fb..990569e3 100644 --- a/auth/google.go +++ b/auth/google.go @@ -55,7 +55,7 @@ func InstallGoogleAuth(app *aero.Application) { app.Get("/auth/google", func(ctx aero.Context) error { state := ctx.Session().ID() url := config.AuthCodeURL(state) - return ctx.Redirect(http.StatusFound, url) + return ctx.Redirect(http.StatusTemporaryRedirect, url) }) // This is the redirect URL that we specified in the OAuth2 config. @@ -122,7 +122,7 @@ func InstallGoogleAuth(app *aero.Application) { // Log authLog.Info("Added Google ID to existing account | %s | %s | %s | %s | %s", user.Nick, user.ID, ctx.IP(), user.Email, user.RealName()) - return ctx.Redirect(http.StatusFound, "/") + return ctx.Redirect(http.StatusTemporaryRedirect, "/") } var getErr error @@ -137,7 +137,7 @@ func InstallGoogleAuth(app *aero.Application) { user.Save() session.Set("userId", user.ID) - return ctx.Redirect(http.StatusFound, "/") + return ctx.Redirect(http.StatusTemporaryRedirect, "/") } // Try to find an existing user via the associated e-mail address @@ -153,7 +153,7 @@ func InstallGoogleAuth(app *aero.Application) { user.Save() session.Set("userId", user.ID) - return ctx.Redirect(http.StatusFound, "/") + return ctx.Redirect(http.StatusTemporaryRedirect, "/") } // Register new user @@ -184,6 +184,6 @@ func InstallGoogleAuth(app *aero.Application) { authLog.Info("Registered new user via Google | %s | %s | %s | %s | %s", user.Nick, user.ID, ctx.IP(), user.Email, user.RealName()) // Redirect to starting page for new users - return ctx.Redirect(http.StatusFound, newUserStartRoute) + return ctx.Redirect(http.StatusTemporaryRedirect, newUserStartRoute) }) } diff --git a/auth/twitter.go b/auth/twitter.go index da5371cc..2752773f 100644 --- a/auth/twitter.go +++ b/auth/twitter.go @@ -53,7 +53,7 @@ func InstallTwitterAuth(app *aero.Application) { ctx.Session().Set("tempCred", tempCred) url := config.AuthorizationURL(tempCred, nil) - return ctx.Redirect(http.StatusFound, url) + return ctx.Redirect(http.StatusTemporaryRedirect, url) }) // This is the redirect URL that we specified in /auth/twitter. @@ -124,7 +124,7 @@ func InstallTwitterAuth(app *aero.Application) { // Log authLog.Info("Added Twitter ID to existing account | %s | %s | %s | %s | %s", user.Nick, user.ID, ctx.IP(), user.Email, user.RealName()) - return ctx.Redirect(http.StatusFound, "/") + return ctx.Redirect(http.StatusTemporaryRedirect, "/") } var getErr error @@ -139,7 +139,7 @@ func InstallTwitterAuth(app *aero.Application) { user.Save() session.Set("userId", user.ID) - return ctx.Redirect(http.StatusFound, "/") + return ctx.Redirect(http.StatusTemporaryRedirect, "/") } // Try to find an existing user via the associated e-mail address @@ -156,7 +156,7 @@ func InstallTwitterAuth(app *aero.Application) { user.Save() session.Set("userId", user.ID) - return ctx.Redirect(http.StatusFound, "/") + return ctx.Redirect(http.StatusTemporaryRedirect, "/") } // Register new user @@ -191,6 +191,6 @@ func InstallTwitterAuth(app *aero.Application) { authLog.Info("Registered new user via Twitter | %s | %s | %s | %s | %s", user.Nick, user.ID, ctx.IP(), user.Email, user.RealName()) // Redirect to starting page for new users - return ctx.Redirect(http.StatusFound, newUserStartRoute) + return ctx.Redirect(http.StatusTemporaryRedirect, newUserStartRoute) }) } diff --git a/go.sum b/go.sum index c27a0c14..e85caf2f 100644 --- a/go.sum +++ b/go.sum @@ -9,6 +9,9 @@ github.com/PuerkitoBio/goquery v1.5.0 h1:uGvmFXOA73IKluu/F84Xd1tt/z07GYm8X49XKHP github.com/PuerkitoBio/goquery v1.5.0/go.mod h1:qD2PgZ9lccMbQlc7eEOjaeRlFQON7xY8kdmcsrnKqMg= github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d h1:G0m3OIz70MZUWq3EgK3CesDbo8upS2Vm9/P3FtgI+Jk= github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= +github.com/aerogo/aero v1.3.1/go.mod h1:5rPhXo2DNMFQ7XhDsuZ3L7Zr6TH/349+WczUbrOUZvM= +github.com/aerogo/aero v1.3.10 h1:KTAscWcducqxa6LcqXe1lJA04E5FPQ6l8MCG3VCNtP4= +github.com/aerogo/aero v1.3.10/go.mod h1:DZA+Yt0AevLyvNG7w1CyYoZZfoFMysABOOrFrgrQhHM= github.com/aerogo/api v0.2.0 h1:mIc/y381e+Qc85eSc2cKPdpDDOmT0hlnEeCw2Dcf7no= github.com/aerogo/api v0.2.0/go.mod h1:6objJn5XiKpYpywQUPrFjxZIXD4NVI2LwcBNYCEcS3Y= github.com/aerogo/cluster v0.1.6 h1:9HYjJwo19uuh9thIc80T3caap9t9b4BXZ1iN8aztjlU= @@ -67,6 +70,7 @@ github.com/akyoto/color v1.8.5 h1:xvHRmBJdsT5HJxnfyIT8l3zNbexA/2YIIeAlaHuhYGY= github.com/akyoto/color v1.8.5/go.mod h1:mI8lhoKcgnvH8fnaupVUE3BmKUp2bpDn5wFS1xEQ4hw= github.com/akyoto/go-matroska v0.1.1 h1:HgoCAkeWrGjYr0FZr3yCzAIkXuOGRiVil7Ul329lm+A= github.com/akyoto/go-matroska v0.1.1/go.mod h1:x+GUVwyby6HN/MKKNP4BvGqP9VrHuEznfBf288gehek= +github.com/akyoto/hash v0.3.5/go.mod h1:uPmnZyhBJIyLON8V9LNi0CcqtwYaH2RiKLFQg67fwq0= github.com/akyoto/hash v0.4.0 h1:M9Q3E6cOAxbf7q3yu5SZZdbZxC4thndCkqJctxl1+zg= github.com/akyoto/hash v0.4.0/go.mod h1:purxg2OohOWT7H0oLP0xQF1DG/EbazUbw7zomRUk8Y8= github.com/akyoto/imageserver v0.3.6 h1:Sxcbgo45Lh7afcSmcU8OS49VYbqh4kE3DK0Lxuuxf74= @@ -274,6 +278,7 @@ golang.org/x/sys v0.0.0-20190516014833-cab07311ab81 h1:5Q88vZAfC0WB8T1GHRLttQaZd golang.org/x/sys v0.0.0-20190516014833-cab07311ab81/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190523142557-0e01d883c5c5 h1:sM3evRHxE/1RuMe1FYAL3j7C7fUfIjkbE+NiDAYUF8U= golang.org/x/sys v0.0.0-20190523142557-0e01d883c5c5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190531175056-4c3a928424d2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190602015325-4c4f7f33c9ed h1:uPxWBzB3+mlnjy9W58qY1j/cjyFjutgw/Vhan2zLy/A= golang.org/x/sys v0.0.0-20190602015325-4c4f7f33c9ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= diff --git a/middleware/HTTPSRedirect.go b/middleware/HTTPSRedirect.go index 8ff84516..b1081cc1 100644 --- a/middleware/HTTPSRedirect.go +++ b/middleware/HTTPSRedirect.go @@ -9,7 +9,7 @@ package middleware // if !strings.HasPrefix(request.Protocol(), "HTTP/2") && isBrowser { // fmt.Println("Redirect to HTTPS") -// ctx.Redirect(http.StatusFound, "https://" + request.Host() + request.URL().Path) +// ctx.Redirect(http.StatusTemporaryRedirect, "https://" + request.Host() + request.URL().Path) // ctx.Response().WriteHeader(ctx.Status()) // return // } diff --git a/middleware/Log.go b/middleware/Log.go index 63438eaa..f1438930 100644 --- a/middleware/Log.go +++ b/middleware/Log.go @@ -75,7 +75,7 @@ func logRequest(ctx aero.Context, responseTime time.Duration) { // Log all requests that failed switch ctx.Status() { - case http.StatusOK, http.StatusFound, http.StatusMovedPermanently, http.StatusPermanentRedirect, http.StatusTemporaryRedirect: + case http.StatusOK, http.StatusTemporaryRedirect, http.StatusPermanentRedirect: // Ok. default: diff --git a/pages/admin/admin.go b/pages/admin/admin.go index 33d7512f..c88fc36b 100644 --- a/pages/admin/admin.go +++ b/pages/admin/admin.go @@ -19,7 +19,7 @@ func Get(ctx aero.Context) error { user := utils.GetUser(ctx) if user == nil || (user.Role != "admin" && user.Role != "editor") { - return ctx.Redirect(http.StatusFound, "/") + return ctx.Redirect(http.StatusTemporaryRedirect, "/") } // // CPU diff --git a/pages/animelist/redirect.go b/pages/animelist/redirect.go index e296146e..3c1cc377 100644 --- a/pages/animelist/redirect.go +++ b/pages/animelist/redirect.go @@ -15,5 +15,5 @@ func Redirect(ctx aero.Context) error { return ctx.Error(http.StatusUnauthorized, "Not logged in") } - return ctx.Redirect(http.StatusFound, "/+" + user.Nick + ctx.Path()) + return ctx.Redirect(http.StatusTemporaryRedirect, "/+" + user.Nick + ctx.Path()) } diff --git a/pages/editor/editor.go b/pages/editor/editor.go index 99d46cf4..17a32cdf 100644 --- a/pages/editor/editor.go +++ b/pages/editor/editor.go @@ -15,7 +15,7 @@ func Get(ctx aero.Context) error { user := utils.GetUser(ctx) if user == nil || (user.Role != "admin" && user.Role != "editor") { - return ctx.Redirect(http.StatusFound, "/") + return ctx.Redirect(http.StatusTemporaryRedirect, "/") } ignoreDifferences := arn.FilterIgnoreAnimeDifferences(func(entry *arn.IgnoreAnimeDifference) bool { diff --git a/pages/editor/filtercompanies/filtercompanies.go b/pages/editor/filtercompanies/filtercompanies.go index 004c50ac..110abf16 100644 --- a/pages/editor/filtercompanies/filtercompanies.go +++ b/pages/editor/filtercompanies/filtercompanies.go @@ -16,7 +16,7 @@ func NoDescription(ctx aero.Context) error { user := utils.GetUser(ctx) if user == nil || (user.Role != "admin" && user.Role != "editor") { - return ctx.Redirect(http.StatusFound, "/") + return ctx.Redirect(http.StatusTemporaryRedirect, "/") } companies := arn.FilterCompanies(func(company *arn.Company) bool { diff --git a/utils/SmartRedirect.go b/utils/SmartRedirect.go index 1afa5b94..d8e9f366 100644 --- a/utils/SmartRedirect.go +++ b/utils/SmartRedirect.go @@ -16,5 +16,5 @@ func SmartRedirect(ctx aero.Context, uri string) error { prefix = "/_" } - return ctx.Redirect(http.StatusFound, prefix+uri) + return ctx.Redirect(http.StatusTemporaryRedirect, prefix+uri) }