mirror of
https://github.com/Arcadia-Solutions/arcadia.git
synced 2026-01-06 01:29:37 -06:00
40 lines
1.1 KiB
Rust
40 lines
1.1 KiB
Rust
use crate::Arcadia;
|
|
use actix_web::{
|
|
web::{Data, Json},
|
|
HttpRequest, HttpResponse,
|
|
};
|
|
use arcadia_common::error::Result;
|
|
use arcadia_storage::{
|
|
models::user_application::{UserApplication, UserCreatedUserApplication},
|
|
redis::RedisPoolInterface,
|
|
sqlx::types::ipnetwork::IpNetwork,
|
|
};
|
|
|
|
#[utoipa::path(
|
|
post,
|
|
operation_id = "Create user application",
|
|
tag = "User Application",
|
|
path = "/api/auth/apply",
|
|
responses(
|
|
(status = 201, description = "Successfully created user application", body = UserApplication)
|
|
)
|
|
)]
|
|
pub async fn exec<R: RedisPoolInterface + 'static>(
|
|
arc: Data<Arcadia<R>>,
|
|
req: HttpRequest,
|
|
application: Json<UserCreatedUserApplication>,
|
|
) -> Result<HttpResponse> {
|
|
let client_ip = req
|
|
.connection_info()
|
|
.realip_remote_addr()
|
|
.and_then(|ip| ip.parse::<IpNetwork>().ok())
|
|
.unwrap();
|
|
|
|
let created_application = arc
|
|
.pool
|
|
.create_user_application(&application.into_inner(), client_ip)
|
|
.await?;
|
|
|
|
Ok(HttpResponse::Created().json(created_application))
|
|
}
|