Improve redirect URI management
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#[derive(serde::Serialize, serde::Deserialize, Debug, Eq, PartialEq, Clone)]
|
||||
pub struct LoginRedirectQuery(String);
|
||||
pub struct LoginRedirect(String);
|
||||
|
||||
impl LoginRedirectQuery {
|
||||
impl LoginRedirect {
|
||||
pub fn get(&self) -> &str {
|
||||
match self.0.starts_with('/') && !self.0.starts_with("//") {
|
||||
true => self.0.as_str(),
|
||||
@@ -14,7 +14,7 @@ impl LoginRedirectQuery {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for LoginRedirectQuery {
|
||||
impl Default for LoginRedirect {
|
||||
fn default() -> Self {
|
||||
Self("/".to_string())
|
||||
}
|
@@ -12,4 +12,4 @@ pub mod code_challenge;
|
||||
pub mod open_id_user_info;
|
||||
pub mod access_token;
|
||||
pub mod totp_key;
|
||||
pub mod login_redirect_query;
|
||||
pub mod login_redirect;
|
@@ -1,5 +1,6 @@
|
||||
use crate::data::client::ClientID;
|
||||
use crate::data::entity_manager::EntityManager;
|
||||
use crate::data::login_redirect::LoginRedirect;
|
||||
use crate::data::totp_key::TotpKey;
|
||||
use crate::utils::err::Res;
|
||||
|
||||
@@ -27,10 +28,10 @@ impl TwoFactor {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn login_url(&self, redirect_uri: &str) -> String {
|
||||
pub fn login_url(&self, redirect_uri: &LoginRedirect) -> String {
|
||||
match self.kind {
|
||||
TwoFactorType::TOTP(_) => format!("/2fa_otp?id={}&redirect_uri={}",
|
||||
self.id.0, redirect_uri)
|
||||
self.id.0, redirect_uri.get_encoded())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user