Better error messages

This commit is contained in:
Eduard Urbach 2017-06-17 23:43:57 +02:00
parent 15e2717ea8
commit 6ae5028a05

View File

@ -51,13 +51,13 @@ func InstallGoogleAuth(app *aero.Application) {
// Auth Callback // Auth Callback
app.Get("/auth/google/callback", func(ctx *aero.Context) string { app.Get("/auth/google/callback", func(ctx *aero.Context) string {
if !ctx.HasSession() { if !ctx.HasSession() {
return ctx.Error(http.StatusUnauthorized, "Session does not exist", errors.New("Google login failed: Session does not exist")) return ctx.Error(http.StatusUnauthorized, "Google login failed", errors.New("Session does not exist"))
} }
session := ctx.Session() session := ctx.Session()
if session.ID() != ctx.Query("state") { if session.ID() != ctx.Query("state") {
return ctx.Error(http.StatusUnauthorized, "Authorization not allowed for this session", errors.New("Google login failed: Incorrect state")) return ctx.Error(http.StatusUnauthorized, "Google login failed", errors.New("Incorrect state"))
} }
// Handle the exchange code to initiate a transport // Handle the exchange code to initiate a transport