Skip to content

Commit

Permalink
cookie will last 2 weeks
Browse files Browse the repository at this point in the history
  • Loading branch information
bryangerlach committed Sep 26, 2023
1 parent fc97228 commit 1d9dcfa
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ dns-lookup = "1.0.8"
ping = "0.4.0"
actix-web = "3.3.3"
rust-argon2 = "2.0"
time = "0.2"

[build-dependencies]
hbb_common = { path = "libs/hbb_common" }
Expand Down
Binary file modified db_v2.sqlite3
Binary file not shown.
7 changes: 6 additions & 1 deletion src/webs.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
extern crate time;
use actix_web::{get, post, web, App, HttpResponse, HttpServer, Responder, cookie::Cookie, HttpRequest, HttpMessage};
use chrono::NaiveDateTime;
use serde::Deserialize;
use sqlx::{sqlite::SqliteConnection, Connection};
use argon2::{self, Config};
use time::{Duration, OffsetDateTime};

#[derive(Debug)]
struct Device {
Expand Down Expand Up @@ -421,8 +423,11 @@ async fn login(form: web::Form<LoginForm>) -> impl Responder {
//password accepted
//println!("password accepted");

let c = Cookie::new("logged_in", "true");
let mut c = Cookie::new("logged_in", "true");
response = web::HttpResponse::Found().header(http::header::LOCATION, "/hello").finish();
let mut now = OffsetDateTime::now_utc();
now += Duration::weeks(2);
c.set_expires(now);
let _ = response.add_cookie(&c);
} else {
//println!("wrong password");
Expand Down

0 comments on commit 1d9dcfa

Please sign in to comment.