Spiegel von
https://github.com/dani-garcia/vaultwarden.git
synchronisiert 2024-12-01 06:31:11 +01:00
Remove some required values during login, now uses default values
Dieser Commit ist enthalten in:
Ursprung
94810c106a
Commit
cb930a0858
8 geänderte Dateien mit 17 neuen und 27 gelöschten Zeilen
|
@ -92,9 +92,9 @@ fn _password_login(data: ConnectData, conn: DbConn, remote: Option<SocketAddr>)
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
let device_type: i32 = util::try_parse_string(data.device_type.as_ref()).expect("Invalid type");
|
let device_type = util::try_parse_string(data.device_type.as_ref()).unwrap_or(0);
|
||||||
let device_id = data.device_identifier.clone().expect("Missing device id");
|
let device_id = data.device_identifier.clone().unwrap_or_else(|| crate::util::get_uuid());
|
||||||
let device_name = data.device_name.clone().expect("Missing device name");
|
let device_name = data.device_name.clone().unwrap_or("unknown_device".into());
|
||||||
|
|
||||||
// Find device or create new
|
// Find device or create new
|
||||||
let mut device = match Device::find_by_uuid(&device_id, &conn) {
|
let mut device = match Device::find_by_uuid(&device_id, &conn) {
|
||||||
|
@ -325,10 +325,7 @@ fn validate_data(data: &ConnectData) -> EmptyResult {
|
||||||
_check_is_some(&data.client_id, "client_id cannot be blank")?;
|
_check_is_some(&data.client_id, "client_id cannot be blank")?;
|
||||||
_check_is_some(&data.password, "password cannot be blank")?;
|
_check_is_some(&data.password, "password cannot be blank")?;
|
||||||
_check_is_some(&data.scope, "scope cannot be blank")?;
|
_check_is_some(&data.scope, "scope cannot be blank")?;
|
||||||
_check_is_some(&data.username, "username cannot be blank")?;
|
_check_is_some(&data.username, "username cannot be blank")
|
||||||
_check_is_some(&data.device_identifier, "device_identifier cannot be blank")?;
|
|
||||||
_check_is_some(&data.device_name, "device_name cannot be blank")?;
|
|
||||||
_check_is_some(&data.device_type, "device_type cannot be blank")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
use chrono::{NaiveDateTime, Utc};
|
use chrono::{NaiveDateTime, Utc};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
||||||
use uuid::Uuid;
|
|
||||||
|
|
||||||
use super::{User, Organization, Attachment, FolderCipher, CollectionCipher, UserOrganization, UserOrgType, UserOrgStatus};
|
use super::{User, Organization, Attachment, FolderCipher, CollectionCipher, UserOrganization, UserOrgType, UserOrgStatus};
|
||||||
|
|
||||||
#[derive(Debug, Identifiable, Queryable, Insertable, Associations)]
|
#[derive(Debug, Identifiable, Queryable, Insertable, Associations)]
|
||||||
|
@ -41,7 +39,7 @@ impl Cipher {
|
||||||
let now = Utc::now().naive_utc();
|
let now = Utc::now().naive_utc();
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
uuid: Uuid::new_v4().to_string(),
|
uuid: crate::util::get_uuid(),
|
||||||
created_at: now,
|
created_at: now,
|
||||||
updated_at: now,
|
updated_at: now,
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
||||||
use uuid::Uuid;
|
|
||||||
|
|
||||||
use super::{Organization, UserOrganization, UserOrgType, UserOrgStatus};
|
use super::{Organization, UserOrganization, UserOrgType, UserOrgStatus};
|
||||||
|
|
||||||
#[derive(Debug, Identifiable, Queryable, Insertable, Associations)]
|
#[derive(Debug, Identifiable, Queryable, Insertable, Associations)]
|
||||||
|
@ -18,7 +16,7 @@ pub struct Collection {
|
||||||
impl Collection {
|
impl Collection {
|
||||||
pub fn new(org_uuid: String, name: String) -> Self {
|
pub fn new(org_uuid: String, name: String) -> Self {
|
||||||
Self {
|
Self {
|
||||||
uuid: Uuid::new_v4().to_string(),
|
uuid: crate::util::get_uuid(),
|
||||||
|
|
||||||
org_uuid,
|
org_uuid,
|
||||||
name,
|
name,
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
use chrono::{NaiveDateTime, Utc};
|
use chrono::{NaiveDateTime, Utc};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
||||||
use uuid::Uuid;
|
|
||||||
|
|
||||||
use super::{User, Cipher};
|
use super::{User, Cipher};
|
||||||
|
|
||||||
#[derive(Debug, Identifiable, Queryable, Insertable, Associations)]
|
#[derive(Debug, Identifiable, Queryable, Insertable, Associations)]
|
||||||
|
@ -33,7 +31,7 @@ impl Folder {
|
||||||
let now = Utc::now().naive_utc();
|
let now = Utc::now().naive_utc();
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
uuid: Uuid::new_v4().to_string(),
|
uuid: crate::util::get_uuid(),
|
||||||
created_at: now,
|
created_at: now,
|
||||||
updated_at: now,
|
updated_at: now,
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
||||||
use uuid::Uuid;
|
|
||||||
use super::{User, CollectionUser, Invitation};
|
use super::{User, CollectionUser, Invitation};
|
||||||
|
|
||||||
#[derive(Debug, Identifiable, Queryable, Insertable)]
|
#[derive(Debug, Identifiable, Queryable, Insertable)]
|
||||||
|
@ -159,7 +158,7 @@ impl Organization {
|
||||||
|
|
||||||
pub fn new(name: String, billing_email: String) -> Self {
|
pub fn new(name: String, billing_email: String) -> Self {
|
||||||
Self {
|
Self {
|
||||||
uuid: Uuid::new_v4().to_string(),
|
uuid: crate::util::get_uuid(),
|
||||||
|
|
||||||
name,
|
name,
|
||||||
billing_email,
|
billing_email,
|
||||||
|
@ -206,7 +205,7 @@ impl Organization {
|
||||||
impl UserOrganization {
|
impl UserOrganization {
|
||||||
pub fn new(user_uuid: String, org_uuid: String) -> Self {
|
pub fn new(user_uuid: String, org_uuid: String) -> Self {
|
||||||
Self {
|
Self {
|
||||||
uuid: Uuid::new_v4().to_string(),
|
uuid: crate::util::get_uuid(),
|
||||||
|
|
||||||
user_uuid,
|
user_uuid,
|
||||||
org_uuid,
|
org_uuid,
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
||||||
use uuid::Uuid;
|
|
||||||
|
|
||||||
use super::User;
|
use super::User;
|
||||||
|
|
||||||
#[derive(Debug, Identifiable, Queryable, Insertable, Associations)]
|
#[derive(Debug, Identifiable, Queryable, Insertable, Associations)]
|
||||||
|
@ -36,7 +34,7 @@ pub enum TwoFactorType {
|
||||||
impl TwoFactor {
|
impl TwoFactor {
|
||||||
pub fn new(user_uuid: String, type_: TwoFactorType, data: String) -> Self {
|
pub fn new(user_uuid: String, type_: TwoFactorType, data: String) -> Self {
|
||||||
Self {
|
Self {
|
||||||
uuid: Uuid::new_v4().to_string(),
|
uuid: crate::util::get_uuid(),
|
||||||
user_uuid,
|
user_uuid,
|
||||||
type_: type_ as i32,
|
type_: type_ as i32,
|
||||||
enabled: true,
|
enabled: true,
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
use chrono::{NaiveDateTime, Utc};
|
use chrono::{NaiveDateTime, Utc};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
||||||
use uuid::Uuid;
|
|
||||||
|
|
||||||
use crate::crypto;
|
use crate::crypto;
|
||||||
use crate::CONFIG;
|
use crate::CONFIG;
|
||||||
|
|
||||||
|
@ -50,7 +48,7 @@ impl User {
|
||||||
let email = mail.to_lowercase();
|
let email = mail.to_lowercase();
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
uuid: Uuid::new_v4().to_string(),
|
uuid: crate::util::get_uuid(),
|
||||||
created_at: now,
|
created_at: now,
|
||||||
updated_at: now,
|
updated_at: now,
|
||||||
name: email.clone(),
|
name: email.clone(),
|
||||||
|
@ -61,7 +59,7 @@ impl User {
|
||||||
salt: crypto::get_random_64(),
|
salt: crypto::get_random_64(),
|
||||||
password_iterations: CONFIG.password_iterations,
|
password_iterations: CONFIG.password_iterations,
|
||||||
|
|
||||||
security_stamp: Uuid::new_v4().to_string(),
|
security_stamp: crate::util::get_uuid(),
|
||||||
|
|
||||||
password_hint: None,
|
password_hint: None,
|
||||||
private_key: None,
|
private_key: None,
|
||||||
|
@ -100,7 +98,7 @@ impl User {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn reset_security_stamp(&mut self) {
|
pub fn reset_security_stamp(&mut self) {
|
||||||
self.security_stamp = Uuid::new_v4().to_string();
|
self.security_stamp = crate::util::get_uuid();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_server_admin(&self) -> bool {
|
pub fn is_server_admin(&self) -> bool {
|
||||||
|
|
|
@ -92,6 +92,10 @@ pub fn get_display_size(size: i32) -> String {
|
||||||
format!("{} {}", size, UNITS[unit_counter])
|
format!("{} {}", size, UNITS[unit_counter])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_uuid() -> String {
|
||||||
|
uuid::Uuid::new_v4().to_string()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// String util methods
|
/// String util methods
|
||||||
|
|
Laden …
In neuem Issue referenzieren