Add: handle not active user

This commit is contained in:
2021-12-13 14:28:24 +08:00
parent ab67575976
commit f1e8dcfad4
4 changed files with 11 additions and 4 deletions

View File

@@ -12,6 +12,7 @@ var (
ErrNotAdmin = errors.New("not admin")
ErrEmpty = errors.New("Empty field detected, please fill in all fields")
ErrAnonymous = errors.New("Anonymous user detected, please login")
ErrNotActive = errors.New("User is not active")
)
type Error struct {

View File

@@ -94,6 +94,12 @@ func (api *API) HandleLogin(w http.ResponseWriter, r *http.Request) {
}
}
// if user is not active
if !user.Active {
api.HandleError(w, r, ErrNotActive)
return
}
// save session
session.Values["userId"] = user.ID
err = session.Save(r, w)