Skip to content

Commit

Permalink
Merge pull request #89 from mprasil/unconfirmed_guard
Browse files Browse the repository at this point in the history
Add confirmed check to the OrgHeaders request guard
  • Loading branch information
dani-garcia authored Jul 17, 2018
2 parents 4a23508 + de72655 commit 458a238
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ use rocket::Outcome;
use rocket::request::{self, Request, FromRequest};

use db::DbConn;
use db::models::{User, UserOrganization, UserOrgType, Device};
use db::models::{User, UserOrganization, UserOrgType, UserOrgStatus, Device};

pub struct Headers {
pub host: String,
Expand Down Expand Up @@ -205,7 +205,13 @@ impl<'a, 'r> FromRequest<'a, 'r> for OrgHeaders {
};

let org_user = match UserOrganization::find_by_user_and_org(&headers.user.uuid, &org_id, &conn) {
Some(user) => user,
Some(user) => {
if user.status == UserOrgStatus::Confirmed as i32 {
user
} else {
err_handler!("The current user isn't confirmed member of the organization")
}
}
None => err_handler!("The current user isn't member of the organization")
};

Expand Down

0 comments on commit 458a238

Please sign in to comment.