aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bin/server.rs17
-rw-r--r--src/handlers/rating.rs1
-rw-r--r--src/handlers/users.rs4
3 files changed, 21 insertions, 1 deletions
diff --git a/src/bin/server.rs b/src/bin/server.rs
index 5af3135..7c67e4f 100644
--- a/src/bin/server.rs
+++ b/src/bin/server.rs
@@ -24,9 +24,24 @@ async fn main() -> std::io::Result<()> {
24 .wrap(IdentityService::new( 24 .wrap(IdentityService::new(
25 CookieIdentityPolicy::new(&private_key) 25 CookieIdentityPolicy::new(&private_key)
26 .name("user-login") 26 .name("user-login")
27 .domain("127.0.0.1")
28 .path("/")
29 .same_site(actix_web::cookie::SameSite::None)
30 .http_only(true)
27 .secure(false), 31 .secure(false),
28 )) 32 ))
29 .wrap(Cors::new().supports_credentials().finish()) 33 .wrap(
34 Cors::default()
35 .allowed_origin("http://127.0.0.1:8000")
36 .allowed_origin("http://localhost:8000")
37 .allow_any_method()
38 .allow_any_header(),
39 )
40 .wrap(
41 middleware::DefaultHeaders::new()
42 .header("Access-Control-Allow-Credentials", "true")
43 .header("Access-Control-Expose-Headers", "set-cookie"),
44 )
30 .wrap(middleware::Logger::default()) 45 .wrap(middleware::Logger::default())
31 .data(pool.clone()) 46 .data(pool.clone())
32 .service( 47 .service(
diff --git a/src/handlers/rating.rs b/src/handlers/rating.rs
index 309c2c6..dfbeb3e 100644
--- a/src/handlers/rating.rs
+++ b/src/handlers/rating.rs
@@ -22,6 +22,7 @@ pub async fn add_rating(
22 pool: web::Data<TPool>, 22 pool: web::Data<TPool>,
23) -> impl Responder { 23) -> impl Responder {
24 info!("Add rating hit: {:?}", rating_details.product_id); 24 info!("Add rating hit: {:?}", rating_details.product_id);
25 info!("{:?}", cookie.identity());
25 let conn = pool.get().unwrap(); 26 let conn = pool.get().unwrap();
26 if let Some(uname) = cookie.identity() { 27 if let Some(uname) = cookie.identity() {
27 let selected_user = customer 28 let selected_user = customer
diff --git a/src/handlers/users.rs b/src/handlers/users.rs
index bff532c..73fca84 100644
--- a/src/handlers/users.rs
+++ b/src/handlers/users.rs
@@ -57,6 +57,10 @@ pub async fn login(
57 login_details: web::Json<Login>, 57 login_details: web::Json<Login>,
58) -> impl Responder { 58) -> impl Responder {
59 info!("Login hit"); 59 info!("Login hit");
60 if let Some(uname) = cookie.identity() {
61 info!("Found existing cookie: {:?}", cookie.identity());
62 return HttpResponse::Ok().finish();
63 }
60 let conn = pool.get().unwrap(); 64 let conn = pool.get().unwrap();
61 let entered_pass = &login_details.password; 65 let entered_pass = &login_details.password;
62 let selected_user = customer 66 let selected_user = customer