11use crate :: { config:: db:: Pool , constants, models:: response:: ResponseBody , utils:: token_utils} ;
22use actix_service:: { Service , Transform } ;
33use actix_web:: {
4- http:: { Method } ,
5- dev:: { ServiceRequest , ServiceResponse } ,
64 Error , HttpResponse ,
5+ dev:: { ServiceRequest , ServiceResponse } ,
6+ http:: { Method , HeaderName , HeaderValue } ,
7+ web:: Data ,
78} ;
89use futures:: {
910 future:: { ok, Ready } ,
@@ -13,7 +14,6 @@ use std::{
1314 pin:: Pin ,
1415 task:: { Context , Poll } ,
1516} ;
16- use actix_web:: http:: header:: { HeaderName , HeaderValue } ;
1717
1818pub struct Authentication ;
1919
@@ -68,17 +68,17 @@ where
6868 }
6969 }
7070 if !authenticate_pass {
71- if let Some ( pool) = req. app_data :: < Pool > ( ) {
71+ if let Some ( pool) = req. app_data :: < Data < Pool > > ( ) {
7272 info ! ( "Connecting to database..." ) ;
73- if let Some ( authen_header) = req. headers_mut ( ) . get ( constants:: AUTHORIZATION ) {
73+ if let Some ( authen_header) = req. headers ( ) . get ( constants:: AUTHORIZATION ) {
7474 info ! ( "Parsing authorization header..." ) ;
7575 if let Ok ( authen_str) = authen_header. to_str ( ) {
7676 if authen_str. starts_with ( "bearer" ) || authen_str. starts_with ( "Bearer" ) {
7777 info ! ( "Parsing token..." ) ;
7878 let token = authen_str[ 6 ..authen_str. len ( ) ] . trim ( ) ;
7979 if let Ok ( token_data) = token_utils:: decode_token ( token. to_string ( ) ) {
8080 info ! ( "Decoding token..." ) ;
81- if token_utils:: verify_token ( & token_data, & pool) . is_ok ( ) {
81+ if token_utils:: verify_token ( & token_data, pool) . is_ok ( ) {
8282 info ! ( "Valid token" ) ;
8383 authenticate_pass = true ;
8484 } else {
0 commit comments