2017-06-17 01:32:47 +02:00
|
|
|
package auth
|
2017-06-11 11:13:59 +02:00
|
|
|
|
|
|
|
import "github.com/aerogo/aero"
|
2017-06-22 22:26:52 +02:00
|
|
|
import "github.com/animenotifier/notify.moe/utils"
|
2017-06-11 11:13:59 +02:00
|
|
|
|
2017-10-06 05:53:49 +02:00
|
|
|
const newUserStartRoute = "/settings"
|
|
|
|
|
2017-11-14 12:35:13 +01:00
|
|
|
// Install installs the authentication routes in the application.
|
2017-06-17 01:32:47 +02:00
|
|
|
func Install(app *aero.Application) {
|
2017-06-15 19:56:09 +02:00
|
|
|
// Google
|
2017-06-17 01:32:47 +02:00
|
|
|
InstallGoogleAuth(app)
|
2017-06-11 11:13:59 +02:00
|
|
|
|
2017-07-02 23:42:46 +02:00
|
|
|
// Facebook
|
|
|
|
InstallFacebookAuth(app)
|
|
|
|
|
2017-06-15 21:59:14 +02:00
|
|
|
// Logout
|
|
|
|
app.Get("/logout", func(ctx *aero.Context) string {
|
2017-06-17 22:19:26 +02:00
|
|
|
if ctx.HasSession() {
|
2017-06-22 22:26:52 +02:00
|
|
|
user := utils.GetUser(ctx)
|
|
|
|
|
|
|
|
if user != nil {
|
|
|
|
authLog.Info("User logged out", user.ID, ctx.RealIP(), user.Email, user.RealName())
|
|
|
|
}
|
|
|
|
|
2017-06-17 22:19:26 +02:00
|
|
|
ctx.Session().Set("userId", nil)
|
|
|
|
}
|
|
|
|
|
2017-06-15 21:59:14 +02:00
|
|
|
return ctx.Redirect("/")
|
|
|
|
})
|
2017-06-11 11:13:59 +02:00
|
|
|
}
|