2024-04-20 11:04:33 +00:00
|
|
|
package services
|
|
|
|
|
|
|
|
import (
|
2024-10-30 16:15:25 +00:00
|
|
|
"git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
|
2024-06-17 14:21:34 +00:00
|
|
|
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
|
2024-04-20 11:04:33 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func GetTicket(id uint) (models.AuthTicket, error) {
|
|
|
|
var ticket models.AuthTicket
|
|
|
|
if err := database.C.
|
|
|
|
Where(&models.AuthTicket{BaseModel: models.BaseModel{ID: id}}).
|
|
|
|
First(&ticket).Error; err != nil {
|
|
|
|
return ticket, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return ticket, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetTicketWithToken(tokenId string) (models.AuthTicket, error) {
|
|
|
|
var ticket models.AuthTicket
|
|
|
|
if err := database.C.
|
|
|
|
Where(models.AuthTicket{AccessToken: &tokenId}).
|
|
|
|
Or(models.AuthTicket{RefreshToken: &tokenId}).
|
|
|
|
First(&ticket).Error; err != nil {
|
|
|
|
return ticket, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return ticket, nil
|
|
|
|
}
|