2017-06-18 17:16:40 +02:00
|
|
|
package settings
|
|
|
|
|
|
|
|
import (
|
2017-06-21 02:51:55 +02:00
|
|
|
"net/http"
|
|
|
|
|
2017-06-18 17:16:40 +02:00
|
|
|
"github.com/aerogo/aero"
|
2019-06-03 18:32:43 +09:00
|
|
|
"github.com/animenotifier/notify.moe/arn"
|
2017-06-18 17:16:40 +02:00
|
|
|
)
|
|
|
|
|
2017-11-05 08:16:20 +01:00
|
|
|
// Get settings.
|
2019-06-01 13:55:49 +09:00
|
|
|
func Get(component func(*arn.User) string) func(aero.Context) error {
|
|
|
|
return func(ctx aero.Context) error {
|
2019-11-17 16:59:34 +09:00
|
|
|
user := arn.GetUserFromContext(ctx)
|
2017-06-18 17:16:40 +02:00
|
|
|
|
2017-11-05 08:16:20 +01:00
|
|
|
if user == nil {
|
2018-07-07 12:42:00 +09:00
|
|
|
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
2017-11-05 08:16:20 +01:00
|
|
|
}
|
2017-06-18 17:16:40 +02:00
|
|
|
|
2017-11-05 08:16:20 +01:00
|
|
|
return ctx.HTML(component(user))
|
|
|
|
}
|
2017-06-18 17:16:40 +02:00
|
|
|
}
|