Add providers buttons on login page
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -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 {
|
||||
|
Reference in New Issue
Block a user