aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel García <[email protected]>2019-04-13 00:01:52 +0200
committerDaniel García <[email protected]>2019-04-13 00:01:52 +0200
commit0136c793b4ac5fb2b5717ac535012f2ee154c96a (patch)
tree2d978e55511a44bbf5204900b2050e5db84a3054
parent2e121143503d0d010db7081f258e7db227ded8cd (diff)
downloadvaultwarden-0136c793b4ac5fb2b5717ac535012f2ee154c96a.tar.gz
vaultwarden-0136c793b4ac5fb2b5717ac535012f2ee154c96a.zip
Implement better user status API, in the future we'll probably want a way to disable users.
We should migrate from the empty password hash to a separate column then.
-rw-r--r--src/db/models/user.rs15
-rw-r--r--src/static/templates/admin/page.hbs6
2 files changed, 17 insertions, 4 deletions
diff --git a/src/db/models/user.rs b/src/db/models/user.rs
index 91d018d7..97617644 100644
--- a/src/db/models/user.rs
+++ b/src/db/models/user.rs
@@ -37,6 +37,12 @@ pub struct User {
pub client_kdf_iter: i32,
}
+enum UserStatus {
+ Enabled = 0,
+ Invited = 1,
+ _Disabled = 2,
+}
+
/// Local methods
impl User {
pub const CLIENT_KDF_TYPE_DEFAULT: i32 = 0; // PBKDF2: 0
@@ -119,8 +125,15 @@ impl User {
let orgs_json: Vec<Value> = orgs.iter().map(|c| c.to_json(&conn)).collect();
let twofactor_enabled = !TwoFactor::find_by_user(&self.uuid, conn).is_empty();
+ // TODO: Might want to save the status field in the DB
+ let status = if self.password_hash.is_empty() {
+ UserStatus::Invited
+ } else {
+ UserStatus::Enabled
+ };
+
json!({
- "_Enabled": !self.password_hash.is_empty(),
+ "_Status": status as i32,
"Id": self.uuid,
"Name": self.name,
"Email": self.email,
diff --git a/src/static/templates/admin/page.hbs b/src/static/templates/admin/page.hbs
index 2cad0e5c..d558ee2b 100644
--- a/src/static/templates/admin/page.hbs
+++ b/src/static/templates/admin/page.hbs
@@ -13,9 +13,9 @@
{{#if TwoFactorEnabled}}
<span class="badge badge-success ml-2">2FA</span>
{{/if}}
- {{#unless _Enabled}}
- <span class="badge badge-warning ml-2">Disabled</span>
- {{/unless}}
+ {{#case _Status 1}}
+ <span class="badge badge-warning ml-2">Invited</span>
+ {{/case}}
<span class="d-block">{{Email}}</span>
</div>
<div class="col">