Load server config on react app
This commit is contained in:
@ -81,19 +81,11 @@ pub struct AppConfig {
|
||||
pub smtp_password: Option<String>,
|
||||
|
||||
/// Password reset URL
|
||||
#[clap(
|
||||
long,
|
||||
env,
|
||||
default_value = "http://localhost:3000/reset_password#TOKEN"
|
||||
)]
|
||||
#[clap(long, env, default_value = "APP_ORIGIN/reset_password#TOKEN")]
|
||||
pub reset_password_url: String,
|
||||
|
||||
/// Delete account URL
|
||||
#[clap(
|
||||
long,
|
||||
env,
|
||||
default_value = "http://localhost:3000/delete_account#TOKEN"
|
||||
)]
|
||||
#[clap(long, env, default_value = "APP_ORIGIN/delete_account#TOKEN")]
|
||||
pub delete_account_url: String,
|
||||
|
||||
/// URL where the OpenID configuration can be found
|
||||
@ -121,8 +113,8 @@ pub struct AppConfig {
|
||||
pub oidc_client_secret: String,
|
||||
|
||||
/// OpenID login redirect URL
|
||||
#[arg(long, env, default_value = "http://localhost:3000/oidc_cb")]
|
||||
pub oidc_redirect_url: String,
|
||||
#[arg(long, env, default_value = "APP_ORIGIN/oidc_cb")]
|
||||
oidc_redirect_url: String,
|
||||
}
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
@ -159,12 +151,16 @@ impl AppConfig {
|
||||
|
||||
/// Get password reset URL
|
||||
pub fn get_password_reset_url(&self, token: &str) -> String {
|
||||
self.reset_password_url.replace("TOKEN", token)
|
||||
self.reset_password_url
|
||||
.replace("APP_ORIGIN", &self.website_origin)
|
||||
.replace("TOKEN", token)
|
||||
}
|
||||
|
||||
/// Get account delete URL
|
||||
pub fn get_account_delete_url(&self, token: &str) -> String {
|
||||
self.delete_account_url.replace("TOKEN", token)
|
||||
self.delete_account_url
|
||||
.replace("APP_ORIGIN", &self.website_origin)
|
||||
.replace("TOKEN", token)
|
||||
}
|
||||
|
||||
/// Get OpenID providers configuration
|
||||
@ -181,6 +177,12 @@ impl AppConfig {
|
||||
name: self.oidc_provider_name.as_str(),
|
||||
}]
|
||||
}
|
||||
|
||||
/// Get OIDC callback URL
|
||||
pub fn oidc_redirect_url(&self) -> String {
|
||||
self.oidc_redirect_url
|
||||
.replace("APP_ORIGIN", &self.website_origin)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize)]
|
||||
|
Reference in New Issue
Block a user