MCPcopy Create free account
hub / github.com/supabase/auth / FindUserWithRefreshToken

Function FindUserWithRefreshToken

internal/models/user.go:640–651  ·  view source on GitHub ↗

FindUserWithRefreshToken finds a user from the provided refresh token. If forUpdate is set to true, then the SELECT statement used by the query has the form SELECT ... FOR UPDATE SKIP LOCKED. This means that a FOR UPDATE lock will only be acquired if there's no other lock. In case there is a lock, a

(tx *storage.Connection, dbEncryption conf.DatabaseEncryptionConfiguration, token string, forUpdate bool)

Source from the content-addressed store, hash-verified

638//
639// Second value returned is either *models.RefreshToken or *crypto.RefreshToken.
640func FindUserWithRefreshToken(tx *storage.Connection, dbEncryption conf.DatabaseEncryptionConfiguration, token string, forUpdate bool) (*User, any, *Session, error) {
641 if len(token) < 12 {
642 // not a valid refresh token so don't bother looking it up in the database
643 return nil, nil, nil, SessionNotFoundError{}
644 }
645
646 if len(token) == 12 {
647 return findUserWithLegacyRefreshToken(tx, token, forUpdate)
648 }
649
650 return findUserWithRefreshToken(tx, dbEncryption, token, forUpdate)
651}
652
653func findUserWithRefreshToken(tx *storage.Connection, dbEncryption conf.DatabaseEncryptionConfiguration, token string, forUpdate bool) (*User, *crypto.RefreshToken, *Session, error) {
654 refreshToken, err := crypto.ParseRefreshToken(token)

Callers 5

RefreshTokenGrantMethod · 0.92
TestLogoutMethod · 0.85

Calls 2

findUserWithRefreshTokenFunction · 0.85

Tested by 4

TestLogoutMethod · 0.68