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