implement email verification feature, add captcha validation middleware, and enhance user authentication flow

This commit is contained in:
2025-07-22 08:50:16 +08:00
parent 6187425df6
commit a0d215fa2e
26 changed files with 844 additions and 50 deletions

23
internal/repo/session.go Normal file
View File

@ -0,0 +1,23 @@
package repo
import "github.com/snowykami/neo-blog/internal/model"
type sessionRepo struct{}
var Session = sessionRepo{}
func (s *sessionRepo) SaveSession(sessionKey string) error {
session := &model.Session{
SessionKey: sessionKey,
}
return db.Create(session).Error
}
func (s *sessionRepo) IsSessionValid(sessionKey string) (bool, error) {
var count int64
err := db.Model(&model.Session{}).Where("session_key = ?", sessionKey).Count(&count).Error
if err != nil {
return false, err
}
return count > 0, nil
}