✨ Auth impl
This commit is contained in:
@ -7,6 +7,17 @@ import (
|
||||
"code.smartsheep.studio/hydrogen/passport/pkg/models"
|
||||
)
|
||||
|
||||
func GetAccount(id uint) (models.Account, error) {
|
||||
var account models.Account
|
||||
if err := database.C.Where(models.Account{
|
||||
BaseModel: models.BaseModel{ID: id},
|
||||
}).First(&account).Error; err != nil {
|
||||
return account, err
|
||||
}
|
||||
|
||||
return account, nil
|
||||
}
|
||||
|
||||
func LookupAccount(id string) (models.Account, error) {
|
||||
var account models.Account
|
||||
if err := database.C.Where(models.Account{Name: id}).First(&account).Error; err == nil {
|
||||
|
18
pkg/services/sessions.go
Normal file
18
pkg/services/sessions.go
Normal file
@ -0,0 +1,18 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
"code.smartsheep.studio/hydrogen/passport/pkg/database"
|
||||
"code.smartsheep.studio/hydrogen/passport/pkg/models"
|
||||
)
|
||||
|
||||
func LookupSessionWithToken(tokenId string) (models.AuthSession, error) {
|
||||
var session models.AuthSession
|
||||
if err := database.C.
|
||||
Where(models.AuthSession{AccessToken: tokenId}).
|
||||
Or(models.AuthSession{RefreshToken: tokenId}).
|
||||
First(&session).Error; err != nil {
|
||||
return session, err
|
||||
}
|
||||
|
||||
return session, nil
|
||||
}
|
Reference in New Issue
Block a user