renamed all instances of "id" to "jwt_sessions_id" to match db column name.
This commit is contained in:
+7
-7
@@ -701,7 +701,7 @@ func RevokeAllUserSessionsExceptCurrent(userID, currentSessionID string) error {
|
||||
}
|
||||
|
||||
_, err = db.DB.Exec(
|
||||
"UPDATE jwt_sessions SET is_revoked = true WHERE user_id = ? AND id != ?",
|
||||
"UPDATE jwt_sessions SET is_revoked = true WHERE user_id = ? AND jwt_sessions_id != ?",
|
||||
userID, currentSessionID,
|
||||
)
|
||||
if err != nil {
|
||||
@@ -724,9 +724,9 @@ func ValidateSession(sessionID string) (*models.JWTSession, error) {
|
||||
err := helper.GetJSON(ctx, sessionKey, &session)
|
||||
if err != nil {
|
||||
err = db.DB.QueryRow(`
|
||||
SELECT id, user_id, refresh_token_hash, user_agent, ip_address, created_at, updated_at, expires_at, is_revoked
|
||||
SELECT jwt_sessions_id, user_id, refresh_token_hash, user_agent, ip_address, created_at, updated_at, expires_at, is_revoked
|
||||
FROM jwt_sessions
|
||||
WHERE id = ?
|
||||
WHERE jwt_sessions_id = ?
|
||||
`, sessionID).Scan(
|
||||
&session.ID,
|
||||
&session.UsersID,
|
||||
@@ -833,7 +833,7 @@ func GetSessionUserInfo(sessionID string) (string, string, error) {
|
||||
func InvalidateUserSessionsInCache(userID string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
rows, err := db.DB.Query("SELECT id, refresh_token_hash FROM jwt_sessions WHERE user_id = ?", userID)
|
||||
rows, err := db.DB.Query("SELECT jwt_sessions_id, refresh_token_hash FROM jwt_sessions WHERE user_id = ?", userID)
|
||||
if err != nil {
|
||||
return fmt.Errorf(errFormatWithContext, errMsgFailedToGetUserSessions, err)
|
||||
}
|
||||
@@ -862,7 +862,7 @@ func InvalidateUserSessionsInCache(userID string) error {
|
||||
func CleanupExpiredSessions() error {
|
||||
ctx := context.Background()
|
||||
|
||||
rows, err := db.DB.Query("SELECT id, user_id, refresh_token_hash FROM jwt_sessions WHERE expires_at < ?", time.Now())
|
||||
rows, err := db.DB.Query("SELECT jwt_sessions_id, user_id, refresh_token_hash FROM jwt_sessions WHERE expires_at < ?", time.Now())
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to query expired sessions: %w", err)
|
||||
}
|
||||
@@ -899,7 +899,7 @@ func CleanupExpiredSessions() error {
|
||||
|
||||
func GetUserSessions(userID string) ([]models.JWTSession, error) {
|
||||
rows, err := db.DB.Query(`
|
||||
SELECT id, user_id, refresh_token_hash, user_agent, ip_address, created_at, updated_at, expires_at, is_revoked
|
||||
SELECT jwt_sessions_id, user_id, refresh_token_hash, user_agent, ip_address, created_at, updated_at, expires_at, is_revoked
|
||||
FROM jwt_sessions
|
||||
WHERE user_id = ? AND is_revoked = false AND expires_at > ?
|
||||
ORDER BY created_at DESC
|
||||
@@ -937,7 +937,7 @@ func UpdateSessionLastActivity(sessionID string) error {
|
||||
_, err := db.DB.Exec(`
|
||||
UPDATE jwt_sessions
|
||||
SET updated_at = ?
|
||||
WHERE id = ?
|
||||
WHERE jwt_sessions_id = ?
|
||||
`, time.Now(), sessionID)
|
||||
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user