diff --git a/src/agent/mod.rs b/src/agent/mod.rs index 2eb0c54..01c04bb 100644 --- a/src/agent/mod.rs +++ b/src/agent/mod.rs @@ -510,21 +510,21 @@ where let client = self.client.as_ref().ok_or(OAuth2Error::NotInitialized)?; let config = self.config.as_ref().ok_or(OAuth2Error::NotInitialized)?; - let post_login_url = Self::current_url().map_err(OAuth2Error::StartLogin)?; + let current_url = Self::current_url().map_err(OAuth2Error::StartLogin)?; // 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)?, - }; + let redirect_url = options + .redirect_url + .or_else(|| { + config + .options + .as_ref() + .and_then(|opts| opts.redirect_url.clone()) + }) + .unwrap_or_else(|| current_url.clone()); - if redirect_url != post_login_url { - SessionStorage::set(STORAGE_KEY_POST_LOGIN_URL, post_login_url) + if redirect_url != current_url { + SessionStorage::set(STORAGE_KEY_POST_LOGIN_URL, current_url) .map_err(|err| OAuth2Error::StartLogin(err.to_string()))?; }