Can change user password
This commit is contained in:
28
src/data/remote_ip.rs
Normal file
28
src/data/remote_ip.rs
Normal file
@@ -0,0 +1,28 @@
|
||||
use std::net::IpAddr;
|
||||
|
||||
use actix_web::{Error, FromRequest, HttpRequest, web};
|
||||
use actix_web::dev::Payload;
|
||||
use futures_util::future::{Ready, ready};
|
||||
|
||||
use crate::data::app_config::AppConfig;
|
||||
use crate::utils::network_utils::get_remote_ip;
|
||||
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||
pub struct RemoteIP(pub IpAddr);
|
||||
|
||||
impl Into<IpAddr> for RemoteIP {
|
||||
fn into(self) -> IpAddr {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl FromRequest for RemoteIP {
|
||||
type Error = Error;
|
||||
type Future = Ready<Result<RemoteIP, Error>>;
|
||||
|
||||
#[inline]
|
||||
fn from_request(req: &HttpRequest, _: &mut Payload) -> Self::Future {
|
||||
let config: &web::Data<AppConfig> = req.app_data().expect("AppData undefined!");
|
||||
ready(Ok(RemoteIP(get_remote_ip(req, config.proxy_ip.as_deref()))))
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user