aboutsummaryrefslogtreecommitdiffstats
path: root/rust/src/database_models.rs
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2019-01-03 16:53:27 -0800
committerBryan Newbold <bnewbold@robocracy.org>2019-01-03 16:53:27 -0800
commit39678e1410a06e99ea71655485786caaf5847e7f (patch)
treed04ba9ae4083892e4d0208be952c98f174d1feef /rust/src/database_models.rs
parent9bfb8e968fcecbe4dc729b89017d0606d271b287 (diff)
downloadfatcat-39678e1410a06e99ea71655485786caaf5847e7f.tar.gz
fatcat-39678e1410a06e99ea71655485786caaf5847e7f.zip
start to impl oidc auth
Diffstat (limited to 'rust/src/database_models.rs')
-rw-r--r--rust/src/database_models.rs28
1 files changed, 26 insertions, 2 deletions
diff --git a/rust/src/database_models.rs b/rust/src/database_models.rs
index 7a65f901..5c8e17d3 100644
--- a/rust/src/database_models.rs
+++ b/rust/src/database_models.rs
@@ -4,7 +4,7 @@ use api_helpers::uuid2fcid;
use chrono;
use database_schema::*;
use errors::*;
-use fatcat_api_spec::models::{ChangelogEntry, Editgroup, EntityEdit};
+use fatcat_api_spec::models::{ChangelogEntry, Editgroup, Editor, EntityEdit};
use serde_json;
use uuid::Uuid;
@@ -559,7 +559,7 @@ pub struct EditgroupRow {
}
impl EditgroupRow {
- /// Returns an Edigroup API model *without* the entity edits actually populated. Useful for,
+ /// Returns an Editgroup API model *without* the entity edits actually populated. Useful for,
/// eg, entity history queries (where we already have the entity edit we want)
pub fn into_model_partial(self) -> Editgroup {
Editgroup {
@@ -579,12 +579,36 @@ pub struct EditorRow {
pub username: String,
pub is_admin: bool,
pub is_bot: bool,
+ pub is_active: bool,
pub registered: chrono::NaiveDateTime,
pub auth_epoch: chrono::NaiveDateTime,
pub wrangler_id: Option<Uuid>,
pub active_editgroup_id: Option<Uuid>,
}
+impl EditorRow {
+ pub fn into_model(self) -> Editor {
+ Editor {
+ editor_id: Some(uuid2fcid(&self.id)),
+ username: self.username,
+ is_admin: Some(self.is_admin),
+ is_bot: Some(self.is_bot),
+ is_active: Some(self.is_active),
+ }
+ }
+}
+
+#[derive(Debug, Clone, Queryable, Associations, AsChangeset)]
+#[table_name = "auth_oidc"]
+pub struct AuthOidcRow {
+ pub id: i64,
+ pub created: chrono::NaiveDateTime,
+ pub editor_id: Uuid,
+ pub provider: String,
+ pub oidc_iss: String,
+ pub oidc_sub: String,
+}
+
#[derive(Debug, Queryable, Identifiable, Associations, AsChangeset)]
#[table_name = "changelog"]
pub struct ChangelogRow {