@@ -58,10 +58,13 @@ use super::{ImageContainer, MdnsChannelMessage};
5858
5959// TODO: Maybe use `std::future::pending::<()>();` instead of sleeping forever
6060
61+ // TODO: Change default admin and guest hashes, remember to search and update where they're hardcoded
6162const SQLITE_URL : & str = "sqlite://data.db" ;
6263const VIDEO_PATH : & str = "./videos/" ;
6364const DEFAULT_ADMIN_USERNAME : & str = "admin" ;
6465const DEFAULT_ADMIN_PASS_HASH : & str = "$argon2id$v=19$m=19456,t=2,p=1$VE0e3g7DalWHgDwou3nuRA$uC6TER156UQpk0lNQ5+jHM0l5poVjPA1he/Tyn9J4Zw" ;
66+ const DEFAULT_GUEST_USERNAME : & str = "guest" ;
67+ const DEFAULT_GUEST_PASS_HASH : & str = "$argon2id$v=19$m=19456,t=2,p=1$VE0e3g7DalWHgDwou3nuRA$uC6TER156UQpk0lNQ5+jHM0l5poVjPA1he/Tyn9J4Zw" ;
6568const EXPIRED_SESSION_DELETION_INTERVAL : tokio:: time:: Duration =
6669 tokio:: time:: Duration :: from_secs ( 60 ) ;
6770const SESSION_DURATION : Duration = Duration :: days ( 1 ) ;
@@ -142,6 +145,21 @@ impl App {
142145 admin. create_using_self ( & self . db ) . await ?;
143146 }
144147
148+ // ? Maybe make this optional just in case
149+ let guest_exists = User :: get_using_username ( & self . db , DEFAULT_GUEST_USERNAME )
150+ . await
151+ . is_ok ( ) ;
152+ if !guest_exists {
153+ let mut guest = User {
154+ user_id : User :: DEFAULT . user_id ,
155+ username : "guest" . to_string ( ) ,
156+ password_hash : DEFAULT_GUEST_PASS_HASH . to_owned ( ) ,
157+ created_at : User :: DEFAULT . created_at ( ) ,
158+ } ;
159+
160+ guest. create_using_self ( & self . db ) . await ?;
161+ }
162+
145163 // Session layer.
146164 //
147165 // This uses `tower-sessions` to establish a layer that will provide the session
0 commit comments