Skip to content

Commit

Permalink
fix: consider agent level redirect URL
Browse files Browse the repository at this point in the history
Closes: #23
  • Loading branch information
ctron committed Jan 19, 2024
1 parent 62187a9 commit 4342e94
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/agent/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,14 @@ where
fn start_login(&mut self, options: LoginOptions) -> Result<(), OAuth2Error> {
let client = self.client.as_ref().ok_or(OAuth2Error::NotInitialized)?;
let config = self.config.as_ref().ok_or(OAuth2Error::NotInitialized)?;
let redirect_url = match options.redirect_url {

// take the parameter value first, then the agent configured value, then fall back to the default
let redirect_url = match options.redirect_url.or_else(|| {
config
.options
.as_ref()
.and_then(|opts| opts.redirect_url.clone())
}) {
Some(redirect_url) => redirect_url,
None => Self::current_url().map_err(OAuth2Error::StartLogin)?,
};
Expand Down

0 comments on commit 4342e94

Please sign in to comment.