From 7babede91f5d630a05e1cf1825dbabb0fa13ba60 Mon Sep 17 00:00:00 2001 From: Peter Sanchez Date: Thu, 3 Nov 2022 13:19:21 -0600 Subject: [PATCH] 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 --- accounts/input.go | 4 ++-- interfaces.go | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/accounts/input.go b/accounts/input.go index c920c97..c6b24a5 100644 --- a/accounts/input.go +++ b/accounts/input.go @@ -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}) } diff --git a/interfaces.go b/interfaces.go index 7742ef7..ee6e578 100644 --- a/interfaces.go +++ b/interfaces.go @@ -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 -- 2.45.2