aboutsummaryrefslogtreecommitdiff
path: root/src/db/models/two_factor.rs
diff options
context:
space:
mode:
authorEmil Madsen <[email protected]>2019-05-20 21:12:41 +0200
committerEmil Madsen <[email protected]>2019-05-20 21:12:41 +0200
commitab95a69dc8be20401bcc3167c51fb5f8b99ed2a2 (patch)
tree97cdac13cbacfb3642d384766a607190dd258567 /src/db/models/two_factor.rs
parent85c8a01f4a0f51efb2432396743878477529b72f (diff)
downloadvaultwarden-ab95a69dc8be20401bcc3167c51fb5f8b99ed2a2.tar.gz
vaultwarden-ab95a69dc8be20401bcc3167c51fb5f8b99ed2a2.zip
Rework migrations for MySQL
Diffstat (limited to 'src/db/models/two_factor.rs')
-rw-r--r--src/db/models/two_factor.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/db/models/two_factor.rs b/src/db/models/two_factor.rs
index fc48313d..30a7b475 100644
--- a/src/db/models/two_factor.rs
+++ b/src/db/models/two_factor.rs
@@ -9,7 +9,7 @@ use super::User;
pub struct TwoFactor {
pub uuid: String,
pub user_uuid: String,
- pub type_: i32,
+ pub atype: i32,
pub enabled: bool,
pub data: String,
}
@@ -32,11 +32,11 @@ pub enum TwoFactorType {
/// Local methods
impl TwoFactor {
- pub fn new(user_uuid: String, type_: TwoFactorType, data: String) -> Self {
+ pub fn new(user_uuid: String, atype: TwoFactorType, data: String) -> Self {
Self {
uuid: crate::util::get_uuid(),
user_uuid,
- type_: type_ as i32,
+ atype: atype as i32,
enabled: true,
data,
}
@@ -53,7 +53,7 @@ impl TwoFactor {
pub fn to_json_list(&self) -> Value {
json!({
"Enabled": self.enabled,
- "Type": self.type_,
+ "Type": self.atype,
"Object": "twoFactorProvider"
})
}
@@ -85,15 +85,15 @@ impl TwoFactor {
pub fn find_by_user(user_uuid: &str, conn: &DbConn) -> Vec<Self> {
twofactor::table
.filter(twofactor::user_uuid.eq(user_uuid))
- .filter(twofactor::type_.lt(1000)) // Filter implementation types
+ .filter(twofactor::atype.lt(1000)) // Filter implementation types
.load::<Self>(&**conn)
.expect("Error loading twofactor")
}
- pub fn find_by_user_and_type(user_uuid: &str, type_: i32, conn: &DbConn) -> Option<Self> {
+ pub fn find_by_user_and_type(user_uuid: &str, atype: i32, conn: &DbConn) -> Option<Self> {
twofactor::table
.filter(twofactor::user_uuid.eq(user_uuid))
- .filter(twofactor::type_.eq(type_))
+ .filter(twofactor::atype.eq(atype))
.first::<Self>(&**conn)
.ok()
}