28 lines
609 B
Go
Raw Normal View History

2018-04-03 23:45:47 +00:00
package user
import (
"net/http"
"github.com/aerogo/aero"
2019-06-03 09:32:43 +00:00
"github.com/animenotifier/notify.moe/arn"
2018-04-03 23:45:47 +00:00
"github.com/animenotifier/notify.moe/utils/editform"
)
// Edit user.
2019-06-01 04:55:49 +00:00
func Edit(ctx aero.Context) error {
2018-04-03 23:45:47 +00:00
nick := ctx.Get("nick")
2019-11-17 07:59:34 +00:00
user := arn.GetUserFromContext(ctx)
2018-04-03 23:45:47 +00:00
if user == nil || user.Role != "admin" {
2018-07-07 03:42:00 +00:00
return ctx.Error(http.StatusUnauthorized, "Not logged in or not auhorized to edit this user")
2018-04-03 23:45:47 +00:00
}
viewUser, err := arn.GetUserByNick(nick)
if err != nil {
return ctx.Error(http.StatusNotFound, "User not found", err)
}
return ctx.HTML(editform.Render(viewUser, "Edit user", user))
}