mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
Return None when auth refresh fails (#20092)
Right now, if Codex winds up in a state with auth but it can't refresh the token, the user is left with an unhelpful message that says to log out and log back in again. Ultimately, we should prevent that from happening but if it does, returning None will allow the caller to redirect the user back to the login page
This commit is contained in:
@@ -148,7 +148,13 @@ impl ModelProvider for ConfiguredModelProvider {
|
||||
let account = if self.info.requires_openai_auth {
|
||||
self.auth_manager
|
||||
.as_ref()
|
||||
.and_then(|auth_manager| auth_manager.auth_cached())
|
||||
.and_then(|auth_manager| {
|
||||
let auth = auth_manager.auth_cached()?;
|
||||
if auth_manager.refresh_failure_for_auth(&auth).is_some() {
|
||||
return None;
|
||||
}
|
||||
Some(auth)
|
||||
})
|
||||
.map(|auth| match &auth {
|
||||
CodexAuth::ApiKey(_) => Ok(ProviderAccount::ApiKey),
|
||||
CodexAuth::Chatgpt(_)
|
||||
|
||||
Reference in New Issue
Block a user