add middleware for api
This commit is contained in:
9
api.go
9
api.go
@@ -34,13 +34,6 @@ func (aH *AccessHandlerAPI) AddUser(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
hash, err := utils.HashPassword(user.Password)
|
||||
if err != nil {
|
||||
aH.logger.Error("AddUser", err)
|
||||
c.JSON(http.StatusInternalServerError, nil)
|
||||
return
|
||||
}
|
||||
|
||||
if !utils.IsValidEmail(user.Email) {
|
||||
aH.logger.Error("AddUser", "not valid email address")
|
||||
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(errors.New("not valid email address")))
|
||||
@@ -48,7 +41,7 @@ func (aH *AccessHandlerAPI) AddUser(c *gin.Context) {
|
||||
}
|
||||
|
||||
// Hash the provided password before saving
|
||||
hash, err = utils.HashPassword(user.Password)
|
||||
hash, err := utils.HashPassword(user.Password)
|
||||
if err != nil {
|
||||
aH.logger.Error("AddUser", err)
|
||||
c.JSON(http.StatusInternalServerError, nil)
|
||||
|
||||
Reference in New Issue
Block a user