modified: begushiybashkir/bbvue/src/stores/auth.js

modified:   begushiybashkir/bbvue/src/views/Register.vue
	modified:   serv_nginx/api_bb/internal/handlers/auth.go
	modified:   serv_nginx/api_bb/internal/models/user.go
	modified:   serv_nginx/api_bb/internal/service/auth_service.go
fix some register bags and set debag info loggers
This commit is contained in:
2025-10-10 04:48:42 +05:00
parent b7252c7900
commit 38c1e43ec2
5 changed files with 105 additions and 43 deletions
+17
View File
@@ -37,4 +37,21 @@ func (u *User) HashPassword() error {
func (u *User) CheckPassword(password string) bool {
err := bcrypt.CompareHashAndPassword([]byte(u.Password), []byte(password))
return err == nil
}
// BeforeCreate hook для GORM
func (u *User) BeforeCreate(tx *gorm.DB) error {
if u.CreatedAt.IsZero() {
u.CreatedAt = time.Now()
}
if u.UpdatedAt.IsZero() {
u.UpdatedAt = time.Now()
}
return u.HashPassword()
}
// BeforeUpdate hook для GORM
func (u *User) BeforeUpdate(tx *gorm.DB) error {
u.UpdatedAt = time.Now()
return nil
}