Skip to content

Commit

Permalink
updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
bhatti committed Dec 2, 2023
1 parent 3dac2a6 commit 45d456c
Show file tree
Hide file tree
Showing 13 changed files with 65 additions and 63 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ Alternatively, you can use Docker for the server by pulling plexpass image as fo
docker pull plexobject/plexpass:latest
docker run -p 8080:8080 -p 8443:8443 -e DEVICE_PEPPER_KEY=$DEVICE_PEPPER_KEY
-e DATA_DIR=/data -e CERT_FILE=/data/cert-pass.pem
-e KEY_FILE=/data/key-pass.pem -v $PARENT_DIR/PlexPassData:/data plexpass server
-e KEY_FILE=/data/key-pass.pem -v $PARENT_DIR/PlexPassData:/data plexobject/plexpass server
```

Note: You only need to run server when using REST APIs or a UI for the web application.
Expand Down
21 changes: 11 additions & 10 deletions assets/javascript/plexpass.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,12 @@ async function viewAccount(id) {
stopFetchingOTP();
});
}
if (account.kind === 'Login') {
expandAccordionSection('collapseLoginInfo');
} else if (account.kind === 'Contact') {
if (account.kind === 'Contacts' || account.category === 'Contacts') {
expandAccordionSection('collapseContactInfo');
} else if (account.kind === 'Notes' || account.kind === 'Custom') {
} else if (account.kind === 'Notes' || account.kind === 'Custom' || account.category === 'Notes' || account.category === 'Custom') {
expandAccordionSection('collapseNotesInfo');
} else if (account.kind === 'Logins' || account.category === 'Logins') {
expandAccordionSection('collapseLoginInfo');
}
await viewModal.show();
}
Expand Down Expand Up @@ -464,18 +464,19 @@ async function showAccountForm(account) {
}

const accountKind = document.getElementById('accountKind').value;
if (accountKind === 'Login') {
const loginCollapse = new bootstrap.Collapse(document.getElementById('collapseLogin'), {
toggle: true
});
} else if (accountKind === 'Contact') {
const editCategory = document.getElementById('editCategory').value;
if (accountKind === 'Contacts' || editCategory === 'Contacts') {
const contactCollapse = new bootstrap.Collapse(document.getElementById('collapseContact'), {
toggle: true
});
} else if (accountKind === 'Notes' || accountKind === 'Custom') {
} else if (accountKind === 'Notes' || accountKind === 'Custom' || editCategory === 'Notes' || editCategory === 'Custom') {
const notesCollapse = new bootstrap.Collapse(document.getElementById('collapseNotes'), {
toggle: true
});
} else if (accountKind === 'Logins' || editCategory === 'Logins') {
const loginCollapse = new bootstrap.Collapse(document.getElementById('collapseLogin'), {
toggle: true
});
}

const editModal = new bootstrap.Modal(document.getElementById('editAccountModal'));
Expand Down
5 changes: 3 additions & 2 deletions functional_tests/00_docker_start_server.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash -e
source env.sh

docker run -p 8080:8080 -p 8443:8443 -e DEVICE_PEPPER_KEY=$DEVICE_PEPPER_KEY -e DATA_DIR=/data -e CERT_FILE=/data/cert-pass.pem -e KEY_FILE=/data/key-pass.pem -v $PARENT_DIR/PlexPassData:/data plexpass server

docker pull plexobject/plexpass
docker run -p 8080:8080 -p 8443:8443 -e DEVICE_PEPPER_KEY=$DEVICE_PEPPER_KEY -e DATA_DIR=/data -e CERT_FILE=/data/cert-pass.pem -e KEY_FILE=/data/key-pass.pem -v $PARENT_DIR/PlexPassData:/data plexobject/plexpass server

6 changes: 3 additions & 3 deletions src/controller/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ impl CreateAccountRequest {
if self.username.is_none() && self.email.is_none() && self.password.is_none() && self.notes.is_some() {
return AccountKind::Notes;
}
AccountKind::Login
AccountKind::Logins
}

pub fn to_account(&self) -> Account {
Expand Down Expand Up @@ -744,7 +744,7 @@ impl UpdateAccountRequest {
if self.username.is_none() && self.email.is_none() && self.password.is_none() && self.notes.is_some() {
return AccountKind::Notes;
}
AccountKind::Login
AccountKind::Logins
}

pub fn to_account(&self) -> Account {
Expand Down Expand Up @@ -834,7 +834,7 @@ async fn load_string_from_multipart(field: &mut Field) -> PassResult<String> {

impl Account {
pub async fn from_multipart(payload: &mut Multipart, new_rec: bool, _config: &PassConfig) -> PassResult<Self> {
let mut account = Self::new("", AccountKind::Login);
let mut account = Self::new("", AccountKind::Logins);
let mut custom_names = vec![];
let mut custom_values = vec![];
while let Some(item) = payload.next().await {
Expand Down
6 changes: 3 additions & 3 deletions src/dao/account_repository_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ mod tests {
assert_eq!(1, vault_repo.create(&ctx, &vault).await.unwrap());

// WHEN creating an account
let mut account = Account::new(&vault.vault_id, AccountKind::Login);
let mut account = Account::new(&vault.vault_id, AccountKind::Logins);

// THEN it should succeed
assert_eq!(1, account_repo.create(&ctx, &account).await.unwrap());
Expand Down Expand Up @@ -654,7 +654,7 @@ mod tests {
assert_eq!(1, vault_repo.create(&ctx, &vault).await.unwrap());

// WHEN creating an account
let account = Account::new(&vault.vault_id, AccountKind::Login);
let account = Account::new(&vault.vault_id, AccountKind::Logins);

// THEN it should succeed
assert_eq!(1, account_repo.create(&ctx, &account).await.unwrap());
Expand Down Expand Up @@ -698,7 +698,7 @@ mod tests {

for i in 0..3 {
// WHEN creating an account
let mut account = Account::new(&vault.vault_id, AccountKind::Login);
let mut account = Account::new(&vault.vault_id, AccountKind::Logins);
// THEN it should succeed only if value has is distinct
if i == 0 {
assert_eq!(1, account_repo.create(&ctx, &account).await.unwrap());
Expand Down
8 changes: 4 additions & 4 deletions src/dao/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1766,7 +1766,7 @@ mod tests {

#[test]
fn test_should_create_account() {
let account = Account::new("vault0", AccountKind::Login);
let account = Account::new("vault0", AccountKind::Logins);
let account_entity = AccountEntity::new(&account, "salt", "nonce", "enc-value");
assert_ne!("", account_entity.account_id.as_str());
assert_eq!("vault0", account_entity.vault_id.as_str());
Expand All @@ -1781,7 +1781,7 @@ mod tests {

#[test]
fn test_should_equal_account() {
let account = Account::new("vault0", AccountKind::Login);
let account = Account::new("vault0", AccountKind::Logins);
let account_entity1 = AccountEntity::new(&account, "salt", "nonce", "enc-value");
let account_entity2 = AccountEntity::new(&account, "salt", "nonce", "enc-value");
assert_eq!(account_entity1, account_entity2);
Expand All @@ -1798,7 +1798,7 @@ mod tests {
let ctx =
UserContext::default_new(&user.username, &user.user_id, &salt, &pepper, "password")
.unwrap();
let account = Account::new("vault0", AccountKind::Login);
let account = Account::new("vault0", AccountKind::Logins);
let account_entity = AccountEntity::new(&account, "salt", "nonce", "enc-value");
let (crypto_key, _) =
CryptoKeyEntity::new_with_input(&ctx, "pass", &user.user_id, "id", "type", "").unwrap();
Expand Down Expand Up @@ -1841,7 +1841,7 @@ mod tests {
)
.unwrap();

let mut account = Account::new("vault0", AccountKind::Login);
let mut account = Account::new("vault0", AccountKind::Logins);
let (mut account_entity, account_crypto_key) = AccountEntity::from_context_vault_account(
&ctx,
&user_crypto_key,
Expand Down
10 changes: 5 additions & 5 deletions src/dao/share_vault_account_repository_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ mod tests {

for i in 0..2 {
// WHEN creating an account
let mut account = Account::new(&vault.vault_id, AccountKind::Login);
let mut account = Account::new(&vault.vault_id, AccountKind::Logins);
account.details.username = Some(format!("user_{}", i.clone()));
account.details.email = Some(format!("email_{}@domain.io", i.clone()));
account.credentials.password = Some(format!("pass_{}", i.clone()));
Expand Down Expand Up @@ -482,7 +482,7 @@ mod tests {

// User 2 should also be able to create accounts for write permissions.
for i in 0..2 {
let mut account = Account::new(&vault.vault_id, AccountKind::Login);
let mut account = Account::new(&vault.vault_id, AccountKind::Logins);
account.details.username = Some(format!("user_{}", i.clone()));
account.details.email = Some(format!("email_{}@domain.io", i.clone()));
account.credentials.password = Some(format!("pass_{}", i.clone()));
Expand Down Expand Up @@ -530,7 +530,7 @@ mod tests {

for i in 0..2 {
// WHEN creating an account
let mut account = Account::new(&vault.vault_id, AccountKind::Login);
let mut account = Account::new(&vault.vault_id, AccountKind::Logins);
account.details.username = Some(format!("user_{}", i.clone()));
account.details.email = Some(format!("email_{}@domain.io", i.clone()));
account.credentials.password = Some(format!("pass_{}", i.clone()));
Expand Down Expand Up @@ -598,7 +598,7 @@ mod tests {

// User 2 should not be able to create accounts for read permissions.
for i in 0..2 {
let mut account = Account::new(&vault.vault_id, AccountKind::Login);
let mut account = Account::new(&vault.vault_id, AccountKind::Logins);
account.details.username = Some(format!("user_{}", i.clone()));
account.details.email = Some(format!("email_{}@domain.io", i.clone()));
account.credentials.password = Some(format!("pass_{}", i.clone()));
Expand Down Expand Up @@ -645,7 +645,7 @@ mod tests {

for i in 0..2 {
// WHEN creating an account
let mut account = Account::new(&vault.vault_id, AccountKind::Login);
let mut account = Account::new(&vault.vault_id, AccountKind::Logins);
account.details.username = Some(format!("user_{}", i.clone()));
account.details.email = Some(format!("email_{}@domain.io", i.clone()));
account.credentials.password = Some(format!("pass_{}", i.clone()));
Expand Down
2 changes: 1 addition & 1 deletion src/domain/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ impl Args {
} else if username.is_none() && email.is_none() && password.is_none() && notes.is_some() {
AccountKind::Notes
} else {
AccountKind::Login
AccountKind::Logins
};
let mut account = Account::new(vault_id, kind);
account.details.label = label.clone();
Expand Down
30 changes: 15 additions & 15 deletions src/domain/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -763,17 +763,17 @@ impl From<&str> for SettingKind {

#[derive(Debug, Clone, Eq, Serialize, Deserialize)]
pub enum AccountKind {
Login,
Contact,
Logins,
Contacts,
Notes,
Custom,
}

impl AccountKind {
pub fn to_vault_kind(&self) -> VaultKind {
match self {
AccountKind::Login => VaultKind::Logins,
AccountKind::Contact => VaultKind::Contacts,
AccountKind::Logins => VaultKind::Logins,
AccountKind::Contacts => VaultKind::Contacts,
AccountKind::Notes => VaultKind::SecureNotes,
AccountKind::Custom => VaultKind::Custom,
}
Expand All @@ -783,8 +783,8 @@ impl AccountKind {
impl Display for AccountKind {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
AccountKind::Login => write!(f, "Login"),
AccountKind::Contact => write!(f, "Contact"),
AccountKind::Logins => write!(f, "Logins"),
AccountKind::Contacts => write!(f, "Contacts"),
AccountKind::Notes => write!(f, "Notes"),
AccountKind::Custom => write!(f, "Custom"),
}
Expand All @@ -800,7 +800,7 @@ impl PartialEq for AccountKind {
impl From<&str> for AccountKind {
fn from(s: &str) -> AccountKind {
match s {
"Login" => AccountKind::Login,
"Login" => AccountKind::Logins,
"Custom" => AccountKind::Custom,
"Notes" => AccountKind::Notes,
_ => {
Expand All @@ -810,7 +810,7 @@ impl From<&str> for AccountKind {
} else if s.contains("data") || s.contains("custom") || s.contains("form") {
AccountKind::Custom
} else {
AccountKind::Login
AccountKind::Logins
}
}
}
Expand Down Expand Up @@ -1404,7 +1404,7 @@ pub const DEFAULT_CATEGORIES: [&str; 10] = [
"Gaming",
"Notes",
"Credit Cards",
"Miscellaneous",
"Custom",
];

pub fn top_categories() -> Vec<String> {
Expand Down Expand Up @@ -2942,7 +2942,7 @@ mod tests {

#[test]
fn test_should_create_account() {
let account = Account::new("vault0", AccountKind::Login);
let account = Account::new("vault0", AccountKind::Logins);
assert_ne!("", &account.details.account_id);
assert_eq!("vault0", &account.vault_id);
assert_eq!(0, account.details.version);
Expand All @@ -2969,7 +2969,7 @@ mod tests {

#[test]
fn test_should_validate_account() {
let mut account = Account::new("vault", AccountKind::Login);
let mut account = Account::new("vault", AccountKind::Logins);
account.details.username = Some("user".into());
account.details.website_url = Some("url".into());
account.credentials.password = Some("pass".into());
Expand All @@ -2980,17 +2980,17 @@ mod tests {

#[test]
fn test_should_before_save_account() {
let mut account = Account::new("vault", AccountKind::Login);
let mut account = Account::new("vault", AccountKind::Logins);
account.details.category = Some("login".into());
account.details.tags = vec!["personal".into(), "work".into()];
account.before_save();
}

#[test]
fn test_should_equal_account() {
let account1 = Account::new("vault1", AccountKind::Login);
let account2 = Account::new("vault1", AccountKind::Login);
let account3 = Account::new("vault1", AccountKind::Login);
let account1 = Account::new("vault1", AccountKind::Logins);
let account2 = Account::new("vault1", AccountKind::Logins);
let account3 = Account::new("vault1", AccountKind::Logins);
assert_ne!(account1.details, account2.details);
assert_ne!(account1.details, account3.details);
let mut hasher = DefaultHasher::new();
Expand Down
6 changes: 3 additions & 3 deletions src/service/account_service_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ mod tests {
assert_eq!(1, vault_service.create_vault(&ctx, &vault).await.unwrap());

// WHEN creating a new account
let mut account = Account::new(&vault.vault_id, AccountKind::Login);
let mut account = Account::new(&vault.vault_id, AccountKind::Logins);
account.details.username = Some("user".into());
account.credentials.password = Some("pass".into());
// THEN it should succeed
Expand Down Expand Up @@ -182,7 +182,7 @@ mod tests {
assert_eq!(1, vault_service.create_vault(&ctx, &vault).await.unwrap());

// WHEN creating a new account
let mut account = Account::new(&vault.vault_id, AccountKind::Login);
let mut account = Account::new(&vault.vault_id, AccountKind::Logins);
account.details.username = Some("user".into());
account.credentials.password = Some("pass".into());
// THEN it should succeed
Expand Down Expand Up @@ -230,7 +230,7 @@ mod tests {

for i in 0..5 {
// WHEN creating a new account
let mut account = Account::new(&vault.vault_id, AccountKind::Login);
let mut account = Account::new(&vault.vault_id, AccountKind::Logins);
account.details.username = Some(format!("user_{}", i));
account.details.category = Some("cat1".into());
account.details.tags = vec!["tag1".into(), "tag2".into()];
Expand Down
2 changes: 1 addition & 1 deletion src/service/otp_service_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl OTPServiceImpl {
.find(|(key, _)| key == "secret")
.map(|(_, value)| value.into_owned()) {
let mut account = AccountResponse::new(
&Account::new("", AccountKind::Login));
&Account::new("", AccountKind::Logins));
account.label = Some(url.domain().unwrap_or("").to_string());
account.otp = Some(secret.to_string());
account.generated_otp = Some(TOTP::new(secret).generate(30, 0));
Expand Down
Loading

0 comments on commit 45d456c

Please sign in to comment.