1
0
Fork 0
Dieser Commit ist enthalten in:
Daniel García 2018-06-01 00:35:30 +02:00
Ursprung a71a2c2f48
Commit 2be1dafe80

Datei anzeigen

@ -6,6 +6,8 @@ use db::models::*;
use api::{PasswordData, JsonResult, EmptyResult, JsonUpcase}; use api::{PasswordData, JsonResult, EmptyResult, JsonUpcase};
use auth::Headers; use auth::Headers;
use util;
use CONFIG; use CONFIG;
#[derive(Deserialize, Debug)] #[derive(Deserialize, Debug)]
@ -13,6 +15,7 @@ use CONFIG;
struct RegisterData { struct RegisterData {
Email: String, Email: String,
Key: String, Key: String,
#[serde(deserialize_with = "util::upcase_deserialize")]
Keys: Option<KeysData>, Keys: Option<KeysData>,
MasterPasswordHash: String, MasterPasswordHash: String,
MasterPasswordHint: Option<String>, MasterPasswordHint: Option<String>,
@ -22,8 +25,8 @@ struct RegisterData {
#[derive(Deserialize, Debug)] #[derive(Deserialize, Debug)]
#[allow(non_snake_case)] #[allow(non_snake_case)]
struct KeysData { struct KeysData {
encryptedPrivateKey: String, EncryptedPrivateKey: String,
publicKey: String, PublicKey: String,
} }
#[post("/accounts/register", data = "<data>")] #[post("/accounts/register", data = "<data>")]
@ -50,8 +53,8 @@ fn register(data: JsonUpcase<RegisterData>, conn: DbConn) -> EmptyResult {
} }
if let Some(keys) = data.Keys { if let Some(keys) = data.Keys {
user.private_key = Some(keys.encryptedPrivateKey); user.private_key = Some(keys.EncryptedPrivateKey);
user.public_key = Some(keys.publicKey); user.public_key = Some(keys.PublicKey);
} }
user.save(&conn); user.save(&conn);
@ -84,8 +87,8 @@ fn post_keys(data: JsonUpcase<KeysData>, headers: Headers, conn: DbConn) -> Json
let mut user = headers.user; let mut user = headers.user;
user.private_key = Some(data.encryptedPrivateKey); user.private_key = Some(data.EncryptedPrivateKey);
user.public_key = Some(data.publicKey); user.public_key = Some(data.PublicKey);
user.save(&conn); user.save(&conn);