Add IP location service
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2022-11-12 17:01:45 +01:00
parent 42d2c20ce3
commit bfe65b0216
278 changed files with 119 additions and 34 deletions

View File

@ -1,6 +1,6 @@
use std::ops::Deref;
use actix_web::{web, HttpResponse, Responder};
use actix_web::{HttpResponse, Responder};
use askama::Template;
use qrcode_generator::QrCodeEcc;
@ -48,14 +48,14 @@ pub async fn two_factors_route(user: CurrentUser) -> impl Responder {
}
/// Configure a new TOTP authentication factor
pub async fn add_totp_factor_route(
user: CurrentUser,
app_conf: web::Data<AppConfig>,
) -> impl Responder {
pub async fn add_totp_factor_route(user: CurrentUser) -> impl Responder {
let key = TotpKey::new_random();
let qr_code =
qrcode_generator::to_png_to_vec(key.url_for_user(&user, &app_conf), QrCodeEcc::Low, 1024);
let qr_code = qrcode_generator::to_png_to_vec(
key.url_for_user(&user, AppConfig::get()),
QrCodeEcc::Low,
1024,
);
let qr_code = match qr_code {
Ok(q) => q,
Err(e) => {
@ -68,7 +68,7 @@ pub async fn add_totp_factor_route(
AddTotpPage {
_p: BaseSettingsPage::get("New authenticator app", &user, None, None),
qr_code: base64::encode(qr_code),
account_name: key.account_name(&user, &app_conf),
account_name: key.account_name(&user, AppConfig::get()),
secret_key: key.get_secret(),
}
.render()