Skip to content

Commit

Permalink
add randomization to quiz, add difficulty levels, udpate quiz configu…
Browse files Browse the repository at this point in the history
…ration, add a check for user profile completion token, add tests
  • Loading branch information
Kirill-K-1 committed Feb 16, 2024
1 parent 7036725 commit f7116dd
Show file tree
Hide file tree
Showing 14 changed files with 916 additions and 145 deletions.
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.

4 changes: 1 addition & 3 deletions config/default.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"listenAddress": "0.0.0.0:10000",
"userDb": {
"secret": null
},
"usersManagerSecret": null,
"signer": {
"signingKey": null,
"requestLifetime": 60000,
Expand Down
1 change: 1 addition & 0 deletions gov-portal-db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ hex = { workspace = true }
base64 = { workspace = true }
anyhow = { workspace = true }
dotenv = { workspace = true }
rand = { workspace = true }

[dev-dependencies]
assert_matches = { workspace = true }
Expand Down
13 changes: 11 additions & 2 deletions gov-portal-db/config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"secret": null,
"lifetime": 86400
},
"registration": {
"usersManager": {
"secret": null,
"lifetime": 600,
"userProfileAttributes": {
Expand All @@ -24,8 +24,17 @@
"requestTimeout": 10
},
"quiz": {
"secret": null,
"timeToSolve": 300,
"failedQuizBlockDuration": 172800,
"minimumValidAnswersRequired": null,
"numberOfQuizQuestionsShown": {
"easy": null,
"moderate": null
},
"minimumValidAnswersRequired": {
"easy": null,
"moderate": null
},
"questions": null
}
}
4 changes: 2 additions & 2 deletions gov-portal-db/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use serde::Deserialize;
use crate::{
quiz::QuizConfig,
session_token::SessionConfig,
users_manager::{mongo_client::MongoConfig, UserRegistrationConfig},
users_manager::{mongo_client::MongoConfig, UsersManagerConfig},
};

#[derive(Deserialize, Debug, Clone)]
Expand All @@ -14,7 +14,7 @@ pub struct AppConfig {
/// Session tokens configuration to allow access to database
pub session: SessionConfig,
/// User registration configuration
pub registration: UserRegistrationConfig,
pub users_manager: UsersManagerConfig,
/// MongoDB client configuration
pub mongo: MongoConfig,
/// Quiz configuration
Expand Down
2 changes: 1 addition & 1 deletion gov-portal-db/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let config = utils::load_config::<config::AppConfig>("./gov-portal-db").await?;

let users_manager =
Arc::new(UsersManager::new(&config.mongo, config.registration.clone()).await?);
Arc::new(UsersManager::new(&config.mongo, config.users_manager.clone()).await?);

server::start(config, users_manager.clone()).await?;

Expand Down
Loading

0 comments on commit f7116dd

Please sign in to comment.