mirror of https://github.com/apibillme/broker
fix auth bug
This commit is contained in:
parent
67ac28aa8f
commit
008d328349
|
@ -386,7 +386,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "broker"
|
||||
version = "0.4.1"
|
||||
version = "0.4.2"
|
||||
dependencies = [
|
||||
"actix-cors 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"actix-rt 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "broker"
|
||||
version = "0.4.1"
|
||||
version = "0.4.2"
|
||||
authors = ["Bevan Hunt <bevan@bevanhunt.com>"]
|
||||
edition = "2018"
|
||||
license = "MIT"
|
||||
|
|
20
src/lib.rs
20
src/lib.rs
|
@ -77,14 +77,16 @@ async fn collection(data: web::Data<MyData>, path: web::Path<Path>, req: HttpReq
|
|||
for part in parts {
|
||||
if part != "Bearer" {
|
||||
let _ = match decode::<Claims>(&part, secret.as_ref(), &Validation::default()) {
|
||||
Ok(c) => c,
|
||||
Ok(c) => {
|
||||
check = check + 1;
|
||||
c
|
||||
},
|
||||
Err(err) => match *err.kind() {
|
||||
_ => return Ok(HttpResponse::Unauthorized().json(""))
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
check = check + 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -167,14 +169,16 @@ async fn insert(data: web::Data<MyData>, json: web::Json<JSON>, req: HttpRequest
|
|||
for part in parts {
|
||||
if part != "Bearer" {
|
||||
let _ = match decode::<Claims>(&part, secret.as_ref(), &Validation::default()) {
|
||||
Ok(c) => c,
|
||||
Ok(c) => {
|
||||
check = check + 1;
|
||||
c
|
||||
},
|
||||
Err(err) => match *err.kind() {
|
||||
_ => return Ok(HttpResponse::Unauthorized().json(""))
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
check = check + 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -214,17 +218,19 @@ async fn cancel(data: web::Data<MyData>, path: web::Path<Path>, req: HttpRequest
|
|||
for part in parts {
|
||||
if part != "Bearer" {
|
||||
let _ = match decode::<Claims>(&part, secret.as_ref(), &Validation::default()) {
|
||||
Ok(c) => c,
|
||||
Ok(c) => {
|
||||
check = check + 1;
|
||||
c
|
||||
},
|
||||
Err(err) => match *err.kind() {
|
||||
_ => return Ok(HttpResponse::Unauthorized().json(""))
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
check = check + 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// if no auth header
|
||||
if check == 0 {
|
||||
return Ok(HttpResponse::Unauthorized().json(""))
|
||||
|
|
Loading…
Reference in New Issue