diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2019-01-11 14:52:44 -0800 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2019-01-11 14:52:44 -0800 |
commit | 54e34ddd56b705cba239f88a9239c603d3ecd20e (patch) | |
tree | 5007cbc2d315d04b5788eb6cec0b7537e8baa51b /rust/src/auth.rs | |
parent | cd5cf1b9f7a50cd3c2f2a42b4a0b3743a5c31d7e (diff) | |
download | fatcat-54e34ddd56b705cba239f88a9239c603d3ecd20e.tar.gz fatcat-54e34ddd56b705cba239f88a9239c603d3ecd20e.zip |
yet more edit lifecycle progress
Diffstat (limited to 'rust/src/auth.rs')
-rw-r--r-- | rust/src/auth.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/rust/src/auth.rs b/rust/src/auth.rs index 8e7160bb..4627a535 100644 --- a/rust/src/auth.rs +++ b/rust/src/auth.rs @@ -11,12 +11,14 @@ use swagger::auth::{AuthData, Authorization, Scopes}; use crate::database_models::*; use crate::database_schema::*; +use crate::editing_crud::{EditgroupCrud, EditorCrud}; use crate::errors::*; use crate::identifiers::*; use crate::server::*; use chrono::prelude::*; use diesel; use diesel::prelude::*; +use fatcat_api_spec::models::{Editgroup, Editor}; use std::collections::HashMap; use std::env; use std::str::FromStr; @@ -73,9 +75,7 @@ impl AuthContext { if self.has_role(FatcatRole::Admin) { return Ok(()); } - let editgroup: EditgroupRow = editgroup::table - .find(editgroup_id.to_uuid()) - .get_result(conn)?; + let editgroup: EditgroupRow = Editgroup::db_get(conn, editgroup_id)?; match editgroup.editor_id == self.editor_id.to_uuid() { true => Ok(()), false => Err(FatcatError::InsufficientPrivileges(format!( @@ -312,7 +312,7 @@ impl AuthConfectionary { "time > {}", created.to_rfc3339_opts(SecondsFormat::Secs, true) )); - let editor: EditorRow = editor::table.find(&editor_id.to_uuid()).get_result(conn)?; + let editor: EditorRow = Editor::db_get(conn, editor_id)?; let auth_epoch = DateTime::<Utc>::from_utc(editor.auth_epoch, Utc); // allow a second of wiggle room for precision and, eg, tests if created < (auth_epoch - chrono::Duration::seconds(1)) { |