mirror of
https://github.com/pocket-id/pocket-id.git
synced 2026-10-26 10:39:06 +01:00
20 lines
494 B
Go
20 lines
494 B
Go
package devicelogin
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"gorm.io/gorm"
|
|
|
|
datatype "github.com/pocket-id/pocket-id/backend/internal/model/types"
|
|
)
|
|
|
|
// CleanupExpiredRequests deletes device login requests that have expired
|
|
// It returns the number of rows removed
|
|
func CleanupExpiredRequests(ctx context.Context, db *gorm.DB) (int64, error) {
|
|
statement := db.
|
|
WithContext(ctx).
|
|
Delete(&Request{}, "expires_at < ?", datatype.DateTime(time.Now()))
|
|
return statement.RowsAffected, statement.Error
|
|
}
|