aboutsummaryrefslogtreecommitdiffstats
path: root/rust/src/api_helpers.rs
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2018-12-28 22:04:45 -0800
committerBryan Newbold <bnewbold@robocracy.org>2018-12-28 22:04:45 -0800
commitd50f7729cbc86c62dba9bd4db80786f07b44a7c0 (patch)
tree992677218f37dbd58fbf3ac7bb6035e3a57a1104 /rust/src/api_helpers.rs
parentf9408344464285870409c2209a8edc8d25fd9bfa (diff)
downloadfatcat-d50f7729cbc86c62dba9bd4db80786f07b44a7c0.tar.gz
fatcat-d50f7729cbc86c62dba9bd4db80786f07b44a7c0.zip
more auth refactoring
Diffstat (limited to 'rust/src/api_helpers.rs')
-rw-r--r--rust/src/api_helpers.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/rust/src/api_helpers.rs b/rust/src/api_helpers.rs
index ff164bef..da208c0a 100644
--- a/rust/src/api_helpers.rs
+++ b/rust/src/api_helpers.rs
@@ -228,6 +228,18 @@ pub fn make_edit_context(
})
}
+// TODO: verify username (alphanum, etc)
+pub fn create_editor(conn: &DbConn, username: String, is_admin: bool, is_bot: bool) -> Result<EditorRow> {
+ let ed: EditorRow = diesel::insert_into(editor::table)
+ .values((
+ editor::username.eq(username),
+ editor::is_admin.eq(is_admin),
+ editor::is_bot.eq(is_bot),
+ ))
+ .get_result(conn)?;
+ Ok(ed)
+}
+
/// This function should always be run within a transaction
pub fn get_or_create_editgroup(editor_id: Uuid, conn: &DbConn) -> Result<Uuid> {
// check for current active