Update backend code to Rust Edition 2024
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:
@ -2,7 +2,7 @@ use crate::app_config::AppConfig;
|
||||
use crate::server::custom_error::HttpResult;
|
||||
use actix_identity::Identity;
|
||||
use actix_remote_ip::RemoteIP;
|
||||
use actix_web::{web, HttpMessage, HttpRequest, HttpResponse};
|
||||
use actix_web::{HttpMessage, HttpRequest, HttpResponse, web};
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
pub struct AuthRequest {
|
||||
@ -17,11 +17,11 @@ pub async fn password_auth(
|
||||
remote_ip: RemoteIP,
|
||||
) -> HttpResult {
|
||||
if r.user != AppConfig::get().admin_username || r.password != AppConfig::get().admin_password {
|
||||
log::error!("Failed login attempt from {}!", remote_ip.0.to_string());
|
||||
log::error!("Failed login attempt from {}!", remote_ip.0);
|
||||
return Ok(HttpResponse::Unauthorized().json("Invalid credentials!"));
|
||||
}
|
||||
|
||||
log::info!("Successful login attempt from {}!", remote_ip.0.to_string());
|
||||
log::info!("Successful login attempt from {}!", remote_ip.0);
|
||||
Identity::login(&request.extensions(), r.user.to_string())?;
|
||||
Ok(HttpResponse::Ok().finish())
|
||||
}
|
||||
|
Reference in New Issue
Block a user