Example #1
0
func (i *UserInter) scopeModel(user *domain.User) error {
	user.CreatedAt = time.Time{}
	user.UpdatedAt = time.Time{}
	user.Account = domain.Account{}

	if user.Password != "" {
		hashedPassword, err := bcrypt.GenerateFromPassword([]byte(user.Password), 0)
		if err != nil {
			return err
		}

		user.Password = string(hashedPassword)
	}

	return nil
}