27 lines
553 B
Go
Raw Normal View History

2017-06-11 09:13:59 +00:00
package main
import "github.com/aerogo/aero"
2017-06-15 17:56:09 +00:00
// EnableLogin ...
func EnableLogin(app *aero.Application) {
// Google
2017-06-11 09:13:59 +00:00
EnableGoogleLogin(app)
2017-06-15 19:59:14 +00:00
// Logout
app.Get("/logout", func(ctx *aero.Context) string {
ctx.Session().Set("userId", nil)
return ctx.Redirect("/")
})
2017-06-11 09:13:59 +00:00
// Session middleware
app.Use(func(ctx *aero.Context, next func()) {
// Handle the request first
next()
// Update session if it has been modified
if ctx.HasSession() && ctx.Session().Modified() {
app.Sessions.Store.Set(ctx.Session().ID(), ctx.Session())
}
})
}