Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bwinf
medal
Commits
3adf053b
Commit
3adf053b
authored
Feb 12, 2019
by
Robert Czechowski
Browse files
Add new admin user when database is empty
parent
c76e13e0
Changes
1
Show whitespace changes
Inline
Side-by-side
src/main.rs
View file @
3adf053b
...
...
@@ -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
()
{
let
opt
=
Opt
::
from_args
();
println!
(
"{:?}"
,
opt
);
...
...
@@ -171,6 +184,7 @@ fn main() {
println!
(
"Hello, world!"
);
let
contest
=
conn
.get_contest_by_id_complete
(
1
);
add_admin_user
(
&
mut
conn
);
println!
(
"Contest {}"
,
contest
.name
);
...
...
Robert Czechowski
@zgtm
mentioned in issue
#21 (closed)
·
Jul 03, 2019
mentioned in issue
#21 (closed)
mentioned in issue #21
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment