mirror of
https://github.com/snowykami/neo-blog.git
synced 2025-09-04 00:06:22 +00:00
⚡ implement email verification feature, add captcha validation middleware, and enhance user authentication flow
This commit is contained in:
23
internal/repo/session.go
Normal file
23
internal/repo/session.go
Normal 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
|
||||
}
|
Reference in New Issue
Block a user