Heavily improved sessions
This commit is contained in:
@ -9,7 +9,10 @@ func Install(app *aero.Application) {
|
||||
|
||||
// Logout
|
||||
app.Get("/logout", func(ctx *aero.Context) string {
|
||||
ctx.Session().Set("userId", nil)
|
||||
if ctx.HasSession() {
|
||||
ctx.Session().Set("userId", nil)
|
||||
}
|
||||
|
||||
return ctx.Redirect("/")
|
||||
})
|
||||
}
|
||||
|
@ -50,6 +50,10 @@ func InstallGoogleAuth(app *aero.Application) {
|
||||
|
||||
// Auth Callback
|
||||
app.Get("/auth/google/callback", func(ctx *aero.Context) string {
|
||||
if !ctx.HasSession() {
|
||||
return ctx.Error(http.StatusUnauthorized, "Session does not exist", errors.New("Google login failed: Session does not exist"))
|
||||
}
|
||||
|
||||
session := ctx.Session()
|
||||
|
||||
if session.ID() != ctx.Query("state") {
|
||||
|
Reference in New Issue
Block a user