Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,9 @@
"backup_file_info": {
"message": "Backup your data to a file."
},
"password_policy_default_hint": {
"message": "Your password does not meet your organization's security requirements. Contact your administrator for more information."
},
"advisor": {
"message": "Advisor"
},
Expand Down
10 changes: 10 additions & 0 deletions manifests/schema-chrome.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@
"title": "Enforce autolock",
"description": "If any value is set, then the user will not be able to change the autolock setting. Set to a number in minutes.",
"type": "number"
},
"passwordPolicy": {
"title": "Password policy",
"description": "A regular expression to test if the password meets the security requirements. No slashes are needed (e.g. use [A-Z]+, but not use /[A-Z]+/).",
"type": "string"
},
"passwordPolicyHint": {
"title": "Password policy hint",
"description": "Hint to show if the password doesn't meet the security requirements.",
"type": "string"
}
}
}
21 changes: 21 additions & 0 deletions src/components/Popup/SetPasswordPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,20 @@ export default Vue.extend({
enforcePassword: function () {
return this.$store.state.menu.enforcePassword;
},
passwordPolicy: function () {
try {
return new RegExp(this.$store.state.menu.passwordPolicy);
} catch {
console.warn(
"Invalid password policy. The password policy is not a valid regular expression.",
this.$store.state.menu.passwordPolicy
);
return null;
}
},
passwordPolicyHint: function () {
return this.$store.state.menu.passwordPolicyHint;
},
},
methods: {
async removePassphrase() {
Expand All @@ -49,6 +63,13 @@ export default Vue.extend({
return;
}

if (this.passwordPolicy && !this.passwordPolicy.test(this.phrase)) {
const hint =
this.passwordPolicyHint || this.i18n.password_policy_default_hint;
this.$store.commit("notification/alert", hint);
return;
}

if (this.phrase !== this.confirm) {
this.$store.commit("notification/alert", this.i18n.phrase_not_match);
return;
Expand Down
2 changes: 2 additions & 0 deletions src/store/Menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export class Menu implements Module {
enforceAutolock: await ManagedStorage.get("enforceAutolock"),
storageArea: await ManagedStorage.get("storageArea"),
feedbackURL: await ManagedStorage.get("feedbackURL"),
passwordPolicy: await ManagedStorage.get("passwordPolicy"),
passwordPolicyHint: await ManagedStorage.get("passwordPolicyHint"),
},
mutations: {
setZoom: (state: MenuState, zoom: number) => {
Expand Down