Remove port from domain on TOPT URI
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:
parent
d46997de14
commit
930cb8bf33
@ -95,6 +95,12 @@ impl AppConfig {
|
|||||||
pub fn domain_name(&self) -> &str {
|
pub fn domain_name(&self) -> &str {
|
||||||
self.website_origin.split('/').nth(2).unwrap_or(APP_NAME)
|
self.website_origin.split('/').nth(2).unwrap_or(APP_NAME)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get the domain without the port
|
||||||
|
pub fn domain_name_without_port(&self) -> &str {
|
||||||
|
let domain = self.domain_name();
|
||||||
|
domain.split_once(':').map(|i| i.0).unwrap_or(domain)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -40,10 +40,10 @@ impl TotpKey {
|
|||||||
pub fn url_for_user(&self, u: &User, conf: &AppConfig) -> String {
|
pub fn url_for_user(&self, u: &User, conf: &AppConfig) -> String {
|
||||||
format!(
|
format!(
|
||||||
"otpauth://totp/{}:{}?secret={}&issuer={}&algorithm=SHA1&digits={}&period={}",
|
"otpauth://totp/{}:{}?secret={}&issuer={}&algorithm=SHA1&digits={}&period={}",
|
||||||
urlencoding::encode(conf.domain_name()),
|
urlencoding::encode(conf.domain_name_without_port()),
|
||||||
urlencoding::encode(&u.username),
|
urlencoding::encode(&u.username),
|
||||||
self.encoded,
|
self.encoded,
|
||||||
urlencoding::encode(conf.domain_name()),
|
urlencoding::encode(conf.domain_name_without_port()),
|
||||||
NUM_DIGITS,
|
NUM_DIGITS,
|
||||||
PERIOD,
|
PERIOD,
|
||||||
)
|
)
|
||||||
@ -53,7 +53,7 @@ impl TotpKey {
|
|||||||
pub fn account_name(&self, u: &User, conf: &AppConfig) -> String {
|
pub fn account_name(&self, u: &User, conf: &AppConfig) -> String {
|
||||||
format!(
|
format!(
|
||||||
"{}:{}",
|
"{}:{}",
|
||||||
urlencoding::encode(conf.domain_name()),
|
urlencoding::encode(conf.domain_name_without_port()),
|
||||||
urlencoding::encode(&u.username)
|
urlencoding::encode(&u.username)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user