Refactor tags services and added tests

Implemented some functionality which will allow the service
configuration of the app to be split among the features for readability
and testability.
This commit is contained in:
Cameron Cordes
2023-03-19 15:05:20 -04:00
parent fbcfc68e01
commit de4041bd17
6 changed files with 143 additions and 50 deletions

View File

@@ -1,4 +1,3 @@
use std::sync::Mutex;
use actix_web::Responder;
use actix_web::{
web::{self, Json},
@@ -7,6 +6,7 @@ use actix_web::{
use chrono::{Duration, Utc};
use jsonwebtoken::{encode, EncodingKey, Header};
use log::{debug, error};
use std::sync::Mutex;
use crate::{
data::{secret_key, Claims, CreateAccountRequest, LoginRequest, Token},
@@ -32,7 +32,10 @@ async fn register<D: UserDao>(
}
}
pub async fn login<D: UserDao>(creds: Json<LoginRequest>, user_dao: web::Data<Mutex<D>>) -> HttpResponse {
pub async fn login<D: UserDao>(
creds: Json<LoginRequest>,
user_dao: web::Data<Mutex<D>>,
) -> HttpResponse {
debug!("Logging in: {}", creds.username);
let mut user_dao = user_dao.lock().expect("Unable to get UserDao");