38 lines
724 B
Go
Raw Normal View History

2017-06-17 01:32:47 +02:00
package auth
2017-06-11 11:13:59 +02:00
2019-05-07 23:01:51 +09:00
import (
2019-06-01 13:55:49 +09:00
"net/http"
2019-05-07 23:01:51 +09:00
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/utils"
)
2017-06-11 11:13:59 +02:00
2018-11-15 12:42:10 +09:00
const newUserStartRoute = "/welcome"
2017-10-06 05:53:49 +02:00
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)
2019-02-08 21:31:59 +01:00
// Twitter
InstallTwitterAuth(app)
2017-06-15 21:59:14 +02:00
// Logout
2019-06-01 13:55:49 +09:00
app.Get("/logout", func(ctx aero.Context) error {
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 {
2019-06-01 13:55:49 +09:00
authLog.Info("%s logged out | %s | %s | %s | %s", user.Nick, user.ID, ctx.IP(), user.Email, user.RealName())
2017-06-22 22:26:52 +02:00
}
2019-05-16 19:15:37 +09:00
ctx.Session().Delete("userId")
2017-06-17 22:19:26 +02:00
}
2019-06-03 15:06:57 +09:00
return ctx.Redirect(http.StatusTemporaryRedirect, "/")
2017-06-15 21:59:14 +02:00
})
2017-06-11 11:13:59 +02:00
}