Add providers buttons on login page
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2023-04-25 14:02:23 +02:00
parent 92d04f3312
commit a0325fefbf
4 changed files with 54 additions and 4 deletions

View File

@@ -1,4 +1,5 @@
use crate::data::entity_manager::EntityManager;
use crate::data::login_redirect::LoginRedirect;
use crate::utils::string_utils::apply_env_vars;
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, Eq, PartialEq)]
@@ -28,6 +29,11 @@ pub struct Provider {
}
impl Provider {
/// Get URL-encoded provider id
pub fn id_encoded(&self) -> String {
urlencoding::encode(&self.id.0).to_string()
}
/// Get the URL where the logo can be located
pub fn logo_url(&self) -> &str {
match self.logo.as_str() {
@@ -39,6 +45,15 @@ impl Provider {
s => s,
}
}
/// Get the URL to use to login with the provider
pub fn login_url(&self, redirect_url: &LoginRedirect) -> String {
format!(
"/login_with_prov?id={}&redirect_url={}",
self.id_encoded(),
redirect_url.get_encoded()
)
}
}
impl PartialEq for Provider {