Refactor login flow
This commit is contained in:
21
src/data/login_redirect_query.rs
Normal file
21
src/data/login_redirect_query.rs
Normal 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())
|
||||
}
|
||||
}
|
@ -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;
|
Reference in New Issue
Block a user