forked from Roflin/gamenight
Added Avanlonia frontend.
This commit is contained in:
@@ -2,8 +2,10 @@ pub mod request;
|
||||
pub mod schema;
|
||||
pub mod util;
|
||||
|
||||
use actix_cors::Cors;
|
||||
use actix_web::HttpServer;
|
||||
use actix_web::App;
|
||||
use actix_web::http;
|
||||
use actix_web::web;
|
||||
use diesel::PgConnection;
|
||||
use diesel::r2d2::{ConnectionManager, Pool};
|
||||
@@ -34,7 +36,16 @@ async fn main() -> std::io::Result<()> {
|
||||
run_migration(&mut conn);
|
||||
|
||||
HttpServer::new(move || {
|
||||
let cors = Cors::default()
|
||||
.allowed_origin("0.0.0.0")
|
||||
.allowed_origin_fn(|_origin, _req_head| { true })
|
||||
.allowed_methods(vec!["GET", "POST"])
|
||||
.allowed_headers(vec![http::header::AUTHORIZATION, http::header::ACCEPT])
|
||||
.allowed_header(http::header::CONTENT_TYPE)
|
||||
.max_age(3600);
|
||||
|
||||
App::new()
|
||||
.wrap(cors)
|
||||
.app_data(web::Data::new(pool.clone()))
|
||||
.service(login)
|
||||
.service(register)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
use actix_web::http::header::ContentType;
|
||||
use actix_web::{web, post, HttpResponse, Responder, get};
|
||||
use actix_web::{web, post, HttpResponse, Responder};
|
||||
use validator::ValidateArgs;
|
||||
use crate::DbPool;
|
||||
use crate::request::requests::{Login, Register};
|
||||
@@ -30,7 +30,7 @@ impl Into<schema::user::Register> for Register {
|
||||
}
|
||||
}
|
||||
|
||||
#[get("/token")]
|
||||
#[post("/token")]
|
||||
pub async fn login(pool: web::Data<DbPool>, login_data: web::Json<Login>) -> Result<impl Responder, ApiError> {
|
||||
let data = login_data.into_inner();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user