Refactor dependencies to reduce code base size (#111)
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Use crates to reduce code base size : * `actix-remote-ip` to safely determine user IP location * `light-openid` for the OpenID primitives & as client to handle federation Reviewed-on: #111
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
use actix::Addr;
|
||||
use actix_remote_ip::RemoteIP;
|
||||
use actix_web::{web, HttpResponse, Responder};
|
||||
use askama::Template;
|
||||
|
||||
@ -9,7 +10,7 @@ use crate::constants::{APP_NAME, MAX_FAILED_LOGIN_ATTEMPTS, MIN_PASS_LEN};
|
||||
use crate::data::action_logger::{Action, ActionLogger};
|
||||
use crate::data::app_config::AppConfig;
|
||||
use crate::data::current_user::CurrentUser;
|
||||
use crate::data::remote_ip::RemoteIP;
|
||||
|
||||
use crate::data::user::User;
|
||||
|
||||
pub(crate) struct BaseSettingsPage<'a> {
|
||||
@ -45,6 +46,7 @@ impl<'a> BaseSettingsPage<'a> {
|
||||
#[template(path = "settings/account_details.html")]
|
||||
struct AccountDetailsPage<'a> {
|
||||
_p: BaseSettingsPage<'a>,
|
||||
remote_ip: String,
|
||||
}
|
||||
|
||||
#[derive(Template)]
|
||||
@ -55,11 +57,12 @@ struct ChangePasswordPage<'a> {
|
||||
}
|
||||
|
||||
/// Account details page
|
||||
pub async fn account_settings_details_route(user: CurrentUser) -> impl Responder {
|
||||
pub async fn account_settings_details_route(user: CurrentUser, ip: RemoteIP) -> impl Responder {
|
||||
let user = user.into();
|
||||
HttpResponse::Ok().body(
|
||||
AccountDetailsPage {
|
||||
_p: BaseSettingsPage::get("Account details", &user, None, None),
|
||||
remote_ip: ip.0.to_string(),
|
||||
}
|
||||
.render()
|
||||
.unwrap(),
|
||||
|
Reference in New Issue
Block a user