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)
| 638 | // |
| 639 | // Second value returned is either *models.RefreshToken or *crypto.RefreshToken. |
| 640 | func 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 | |
| 653 | func findUserWithRefreshToken(tx *storage.Connection, dbEncryption conf.DatabaseEncryptionConfiguration, token string, forUpdate bool) (*User, *crypto.RefreshToken, *Session, error) { |
| 654 | refreshToken, err := crypto.ParseRefreshToken(token) |