Refactor login flow

This commit is contained in:
2022-04-19 17:49:57 +02:00
parent 78d70af510
commit 5903ec2e8c
6 changed files with 117 additions and 76 deletions

View File

@ -0,0 +1,21 @@
#[derive(serde::Serialize, serde::Deserialize, Debug, Eq, PartialEq, Clone)]
pub struct LoginRedirectQuery(String);
impl LoginRedirectQuery {
pub fn get(&self) -> &str {
match self.0.starts_with('/') && !self.0.starts_with("//") {
true => self.0.as_str(),
false => "/",
}
}
pub fn get_encoded(&self) -> String {
urlencoding::encode(self.get()).to_string()
}
}
impl Default for LoginRedirectQuery {
fn default() -> Self {
Self("/".to_string())
}
}

View File

@ -11,4 +11,5 @@ pub mod id_token;
pub mod code_challenge;
pub mod open_id_user_info;
pub mod access_token;
pub mod totp_key;
pub mod totp_key;
pub mod login_redirect_query;