GetUserCodeSession returns a user code session from the database. Implements FositeStorer.
(ctx context.Context, signature string, session fosite.Session)
| 210 | |
| 211 | // GetUserCodeSession returns a user code session from the database. Implements FositeStorer. |
| 212 | func (p *Persister) GetUserCodeSession(ctx context.Context, signature string, session fosite.Session) (_ fosite.DeviceRequester, err error) { |
| 213 | ctx, span := p.r.Tracer(ctx).Tracer().Start(ctx, "persistence.sql.GetUserCodeSession") |
| 214 | defer otelx.End(span, &err) |
| 215 | |
| 216 | r := DeviceRequestSQL{} |
| 217 | if session == nil { |
| 218 | session = oauth2.NewSessionWithCustomClaims(ctx, p.r.Config(), "") |
| 219 | } |
| 220 | |
| 221 | if err = p.QueryWithNetwork(ctx).Where("user_code_signature = ?", signature).First(&r); errors.Is(err, sql.ErrNoRows) { |
| 222 | return nil, errors.WithStack(fosite.ErrNotFound) |
| 223 | } else if err != nil { |
| 224 | return nil, sqlcon.HandleError(err) |
| 225 | } |
| 226 | |
| 227 | fr, err := r.toRequest(ctx, session, p) |
| 228 | if err != nil { |
| 229 | return nil, err |
| 230 | } |
| 231 | |
| 232 | if r.UserCodeState != fosite.UserCodeUnused { |
| 233 | return fr, errors.WithStack(fosite.ErrInactiveToken) |
| 234 | } |
| 235 | |
| 236 | return fr, err |
| 237 | } |
| 238 | |
| 239 | // GetDeviceCodeSessionByRequestID returns a device code session from the database. Implements FositeStorer. |
| 240 | func (p *Persister) GetDeviceCodeSessionByRequestID(ctx context.Context, requestID string, session fosite.Session) (_ fosite.DeviceRequester, deviceCodeSignature string, err error) { |
nothing calls this directly
no test coverage detected