Login executes the provider login flow and persists the resulting auth record.
(ctx context.Context, provider string, cfg *config.Config, opts *LoginOptions)
| 45 | |
| 46 | // Login executes the provider login flow and persists the resulting auth record. |
| 47 | func (m *Manager) Login(ctx context.Context, provider string, cfg *config.Config, opts *LoginOptions) (*coreauth.Auth, string, error) { |
| 48 | auth, ok := m.authenticators[provider] |
| 49 | if !ok { |
| 50 | return nil, "", fmt.Errorf("cliproxy auth: authenticator %s not registered", provider) |
| 51 | } |
| 52 | |
| 53 | record, err := auth.Login(ctx, cfg, opts) |
| 54 | if err != nil { |
| 55 | return nil, "", err |
| 56 | } |
| 57 | if record == nil { |
| 58 | return nil, "", fmt.Errorf("cliproxy auth: authenticator %s returned nil record", provider) |
| 59 | } |
| 60 | |
| 61 | if m.store == nil { |
| 62 | return record, "", nil |
| 63 | } |
| 64 | |
| 65 | if cfg != nil { |
| 66 | if dirSetter, ok := m.store.(interface{ SetBaseDir(string) }); ok { |
| 67 | dirSetter.SetBaseDir(cfg.AuthDir) |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | savedPath, err := m.store.Save(ctx, record) |
| 72 | if err != nil { |
| 73 | return record, "", err |
| 74 | } |
| 75 | return record, savedPath, nil |
| 76 | } |
nothing calls this directly
no test coverage detected