Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/spreed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2022-06-30 10:20:10 +0300
committerGitHub <noreply@github.com>2022-06-30 10:20:10 +0300
commit57b28f64d6b02a7879da51e7c264a87472e94ed8 (patch)
treee10748717b5f037be4b65e29f613179b9bef74a3 /src
parentd0d015820077fd8d8d559474f8b2d1ac9196421f (diff)
parent5fdedaa290eb8ba1801373ca04a7953af8e8711b (diff)
Merge pull request #7473 from nextcloud/feature/3089/password-policy
Implement password policy checker
Diffstat (limited to 'src')
-rw-r--r--src/components/ConversationSettings/LinkShareSettings.vue10
-rw-r--r--src/components/LeftSidebar/NewGroupConversation/PasswordProtect/PasswordProtect.vue43
-rw-r--r--src/services/conversationsService.js7
3 files changed, 57 insertions, 3 deletions
diff --git a/src/components/ConversationSettings/LinkShareSettings.vue b/src/components/ConversationSettings/LinkShareSettings.vue
index 8b53cb0d6..14706ed41 100644
--- a/src/components/ConversationSettings/LinkShareSettings.vue
+++ b/src/components/ConversationSettings/LinkShareSettings.vue
@@ -163,9 +163,13 @@ export default {
} else {
showSuccess(t('spreed', 'Conversation password has been removed'))
}
- } catch (e) {
- console.error('Error saving conversation password', e)
- showError(t('spreed', 'Error occurred while saving conversation password'))
+ } catch (error) {
+ console.error('Error saving conversation password', error)
+ if (error?.response?.data?.ocs?.data?.message) {
+ showError(error.response.data.ocs.data.message)
+ } else {
+ showError(t('spreed', 'Error occurred while saving conversation password'))
+ }
}
this.isSaving = false
},
diff --git a/src/components/LeftSidebar/NewGroupConversation/PasswordProtect/PasswordProtect.vue b/src/components/LeftSidebar/NewGroupConversation/PasswordProtect/PasswordProtect.vue
index c2142988a..59e193fb3 100644
--- a/src/components/LeftSidebar/NewGroupConversation/PasswordProtect/PasswordProtect.vue
+++ b/src/components/LeftSidebar/NewGroupConversation/PasswordProtect/PasswordProtect.vue
@@ -22,16 +22,22 @@
<template>
<input ref="password"
v-observe-visibility="visibilityChanged"
+ v-tooltip.bottom="reason"
type="password"
autocomplete="new-password"
:value="value"
class="password-protect"
+ :class="{'weak-password': validPassword === false}"
:placeholder="t('spreed', 'Choose a password')"
+ :aria-label="reason"
@input="handleInput">
</template>
<script>
+import { validatePassword } from '../../../../services/conversationsService.js'
+import debounce from 'debounce'
+
export default {
name: 'PasswordProtect',
@@ -42,10 +48,41 @@ export default {
},
},
+ data() {
+ return {
+ validPassword: null,
+ reason: '',
+ }
+ },
+
methods: {
handleInput(event) {
this.$emit('input', event.target.value)
+ if (event.target.value !== '') {
+ this.debounceValidatePassword()
+ }
+ },
+
+ debounceValidatePassword: debounce(function() {
+ this.validatePassword()
+ }, 250),
+
+ async validatePassword() {
+ try {
+ const response = await validatePassword(this.value)
+ this.validPassword = response.data.ocs.data.passed
+ if (!this.validPassword) {
+ this.reason = response.data.ocs.data.reason
+ } else {
+ this.reason = ''
+ }
+ } catch (e) {
+ console.debug('Password policy app seems not enabled')
+ this.validPassword = null
+ this.reason = ''
+ }
},
+
visibilityChanged(isVisible) {
if (isVisible) {
// Focus the input field of the current component.
@@ -63,5 +100,11 @@ export default {
.password-protect {
width: calc(100% - 18px);
margin-left: 18px;
+
+ &.weak-password {
+ background-color: var(--color-error) !important;
+ border-color: var(--color-error) !important;
+ color: #fff !important;
+ }
}
</style>
diff --git a/src/services/conversationsService.js b/src/services/conversationsService.js
index 7c01e88a6..bf9b3e7d1 100644
--- a/src/services/conversationsService.js
+++ b/src/services/conversationsService.js
@@ -390,6 +390,12 @@ const setCallPermissions = async (token, permissions) => {
})
}
+const validatePassword = async (password) => {
+ return await axios.post(generateOcsUrl('apps/password_policy/api/v1/validate'), {
+ password,
+ })
+}
+
export {
fetchConversations,
fetchConversation,
@@ -416,4 +422,5 @@ export {
clearConversationHistory,
setConversationPermissions,
setCallPermissions,
+ validatePassword,
}