User implements a group that handle /user requests.



This section is empty.


This section is empty.


This section is empty.


type AuthCtx

type AuthCtx struct {
	Me *models.User

AuthCtx is a context that holds the "me" user.

func Me

func Me(db db.DBContext, c echo.Context) (*AuthCtx, error)

Me returns the "me" user context.

func (*AuthCtx) GetMe

func (a *AuthCtx) GetMe() *models.User

GetMe implements template.Me

type ChangePasswordForm

type ChangePasswordForm struct {
	CurrentPassword string `form:"current_password"`
	NewPassword     string `form:"new_password"`

ChangePasswordForm is the form handling a password change request.

func (*ChangePasswordForm) Bind

func (c *ChangePasswordForm) Bind(u *models.User) error

Bind binds the content of the form into the user.

type Group

type Group struct {

	// contains filtered or unexported fields


Group is the /user handling group.

func New

func New(db *db.DB, g *echo.Group) (*Group, error)

New creates a new Group.

func (*Group) ChangePassword

func (g *Group) ChangePassword(c echo.Context) error

ChangePassword implements POST /user/change_password.

func (*Group) HomeGet

func (g *Group) HomeGet(c echo.Context) error

HomeGet implements "/user".

func (*Group) LoginGet

func (g *Group) LoginGet(c echo.Context) error

LoginGet implements GET /user/login.

func (*Group) LoginPost

func (g *Group) LoginPost(c echo.Context) error

LoginPost implements POST /user/login.

func (*Group) LogoutPost

func (g *Group) LogoutPost(c echo.Context) error

LogoutPost implements GET/POST /user/logout.

func (*Group) RegisterPost

func (g *Group) RegisterPost(c echo.Context) error

RegisterPost implements POST /user/register

type HomeCtx

type HomeCtx struct {

	ChangePasswordError error
	ChangePassword      ChangePasswordForm

HomeCtx is the context to render the /user page.

func (*HomeCtx) Render

func (h *HomeCtx) Render(c echo.Context) error

Render renders the context.

type LoginCtx

type LoginCtx struct {
	AllowRegistration bool

	Error error

LoginCtx represents the context to render logins.

func (*LoginCtx) Render

func (l *LoginCtx) Render(c echo.Context) error

Render performs rendering for the context.

type LoginForm

type LoginForm struct {
	ID       string `form:"id"`
	Password string `form:"password"`
	Remember bool   `form:"remember"`