Commit 3adf053b authored by Robert Czechowski's avatar Robert Czechowski
Browse files

Add new admin user when database is empty

parent c76e13e0
...@@ -150,6 +150,19 @@ fn refresh_all_contests(conn : &mut Connection) { ...@@ -150,6 +150,19 @@ fn refresh_all_contests(conn : &mut Connection) {
} }
} }
fn add_admin_user(conn: &mut Connection) {
if conn.get_user_by_id(1).is_none() {
print!("New Database. Creating new admin user with credentials 'admin':'test' … ");
let mut admin = conn.new_session();
admin.username = Some("admin".into());
admin.password = Some("test".into());
admin.salt = Some("".into());
conn.save_session(admin);
println!("Done");
}
}
fn main() { fn main() {
let opt = Opt::from_args(); let opt = Opt::from_args();
println!("{:?}", opt); println!("{:?}", opt);
...@@ -171,6 +184,7 @@ fn main() { ...@@ -171,6 +184,7 @@ fn main() {
println!("Hello, world!"); println!("Hello, world!");
let contest = conn.get_contest_by_id_complete(1); let contest = conn.get_contest_by_id_complete(1);
add_admin_user(&mut conn);
println!("Contest {}", contest.name); println!("Contest {}", contest.name);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment