~netlandish/gobwebs

7babede91f5d630a05e1cf1825dbabb0fa13ba60 — Peter Sanchez 2 years ago 0ad1717
Adding ProcessLogin method to UserFetch interface. Removing is_verified requirement in login. Now you can use ProcessLogin for that verification should you want it in your app
2 files changed, 8 insertions(+), 2 deletions(-)

M accounts/input.go
M interfaces.go
M accounts/input.go => accounts/input.go +2 -2
@@ 62,8 62,8 @@ func (l *LoginForm) Validate(c echo.Context, fetch gobwebs.UserFetch) error {
		return validate.GetInputErrors([]error{err})
	}

	if !user.IsVerified() {
		err = fmt.Errorf(lt.Translate("You must verify your email address before logging in"))
	err = fetch.ProcessLogin(c, user)
	if err != nil {
		return validate.GetInputErrors([]error{err})
	}


M interfaces.go => interfaces.go +6 -0
@@ 47,6 47,12 @@ type UserFetch interface {
	// Helpers to customize the behavior of accounts handlers
	LoginType() int

	// Run any user checks before actually logging the user in.
	// Ie, checking if the user has `is_verified` set to true
	// Any error returned will raise an error in the LoginForm
	// validation in accounts
	ProcessLogin(c echo.Context, user User) error

	ProcessSuccessfulLogin(c echo.Context, user User) error
	ProcessSuccessfulLogout(c echo.Context) error
	ProcessSuccessfulPasswordChange(c echo.Context) error