updated styleguide to 0.5.17, fixed password cross validation & display passwordstrength on passwordchange

This commit is contained in:
Ulf Gebhardt 2019-05-07 20:22:38 +02:00
parent 305c999321
commit 0f2c0f7efe
No known key found for this signature in database
GPG Key ID: 44C888923CC8E7F3
6 changed files with 66 additions and 31 deletions

View File

@ -1,5 +1,11 @@
<template> <template>
<ds-form v-model="formData" :schema="formSchema" @submit="handleSubmit" @input="handleInput"> <ds-form
v-model="formData"
:schema="formSchema"
@submit="handleSubmit"
@input="handleInput"
@input-valid="handleInputValid"
>
<template> <template>
<ds-input <ds-input
id="oldPassword" id="oldPassword"
@ -19,7 +25,7 @@
type="password" type="password"
:label="$t('settings.security.change-password.label-new-password-confirm')" :label="$t('settings.security.change-password.label-new-password-confirm')"
/> />
<password-strength :password="formData.newPassword" @change="handlePasswordStrength"/> <password-strength :password="formData.newPassword"/>
<ds-space margin-top="base"> <ds-space margin-top="base">
<ds-button <ds-button
:loading="loading" :loading="loading"
@ -49,23 +55,29 @@ export default {
}, },
formSchema: { formSchema: {
oldPassword: { oldPassword: {
type: 'string',
required: true, required: true,
message: this.$t( message: this.$t(
'settings.security.change-password.message-old-password-required' 'settings.security.change-password.message-old-password-required'
) )
}, },
newPassword: { newPassword: {
type: 'string',
required: true, required: true,
message: this.$t( message: this.$t(
'settings.security.change-password.message-new-password-required' 'settings.security.change-password.message-new-password-required'
) )
}, },
confirmPassword: { confirmPassword: [
required: true, { validator: this.matchPassword },
message: this.$t( {
'settings.security.change-password.message-new-password-confirm-required' type: 'string',
) required: true,
} message: this.$t(
'settings.security.change-password.message-new-password-confirm-required'
)
}
]
}, },
loading: false, loading: false,
disabled: true disabled: true
@ -73,13 +85,10 @@ export default {
}, },
methods: { methods: {
async handleInput(data) { async handleInput(data) {
console.log('validation') this.disabled = true
console.log(data) },
if (data.newPassword && data.newPassword === data.confirmPassword) { async handleInputValid(data) {
this.disabled = false this.disabled = false
} else {
this.disabled = true
}
}, },
async handleSubmit(data) { async handleSubmit(data) {
this.loading = true this.loading = true
@ -102,8 +111,18 @@ export default {
this.loading = false this.loading = false
} }
}, },
handlePasswordStrength(e) { matchPassword(rule, value, callback, source, options) {
console.log(e.isSecure) var errors = []
if (this.formData.newPassword !== value) {
errors.push(
new Error(
this.$t(
'settings.security.change-password.message-new-password-missmatch'
)
)
)
}
callback(errors)
} }
} }
} }

View File

@ -3,12 +3,10 @@
<div class="password-strength-meter"> <div class="password-strength-meter">
<div class="password-strength-meter-inner" :class="strengthClass"></div> <div class="password-strength-meter-inner" :class="strengthClass"></div>
</div> </div>
{{ pass }}
{{ password }}
<p class="help"> <p class="help">
<span v-if="this.pass" :class="{ insecure: (passwordStrength < 3) }"> <span v-if="this.pass" :class="{ insecure: (passwordStrength < 3) }">
{{ $t('auth.register.passwordSecurity') }}: {{ $t('settings.security.change-password.passwordSecurity') }}:
<strong>{{ $t(`auth.register.passwordStrength${passwordStrength}`) }}</strong> <strong>{{ $t(`settings.security.change-password.passwordStrength${passwordStrength}`) }}</strong>
</span> </span>
<span v-else>&nbsp;</span> <span v-else>&nbsp;</span>
</p> </p>

View File

@ -49,7 +49,14 @@
"label-new-password-confirm": "Bestätige Dein neues Passwort", "label-new-password-confirm": "Bestätige Dein neues Passwort",
"message-old-password-required": "Gebe dein altes Passwort ein", "message-old-password-required": "Gebe dein altes Passwort ein",
"message-new-password-required": "Gebe ein neues Passwort ein", "message-new-password-required": "Gebe ein neues Passwort ein",
"message-new-password-confirm-required": "Bestätige dein neues Passwort" "message-new-password-confirm-required": "Bestätige dein neues Passwort",
"message-new-password-missmatch": "Gebe das gleiche Passwort nochmals ein",
"passwordSecurity": "Passwortsicherheit",
"passwordStrength0": "Sehr unsicheres Passwort",
"passwordStrength1": "Unsicheres Passwort",
"passwordStrength2": "Mittelmäßiges Passwort",
"passwordStrength3": "Sicheres Passwort",
"passwordStrength4": "Sehr sicheres Passwort"
} }
}, },
"invites": { "invites": {

View File

@ -49,7 +49,14 @@
"label-new-password-confirm": "Confirm new password", "label-new-password-confirm": "Confirm new password",
"message-old-password-required": "Enter your old password", "message-old-password-required": "Enter your old password",
"message-new-password-required": "Enter a new password", "message-new-password-required": "Enter a new password",
"message-new-password-confirm-required": "Confirm your new password" "message-new-password-confirm-required": "Confirm your new password",
"message-new-password-missmatch": "Type the same password again",
"passwordSecurity": "Password security",
"passwordStrength0": "Very insecure password",
"passwordStrength1": "Insecure password",
"passwordStrength2": "Mediocre password",
"passwordStrength3": "Strong password",
"passwordStrength4": "Very strong password"
} }
}, },
"invites": { "invites": {

View File

@ -1,9 +1,13 @@
{ {
"name": "hc-webapp-next", "name": "hc-webapp-next",
"version": "1.0.0", "version": "1.0.0",
"description": "Human Connection GraphQL UI Prototype", "description": "Human Connection Frontend",
"author": "Grzegorz Leoniec", "authors": [
"private": true, "Grzegorz Leoniec (appinteractive)",
"ulfgebhardt"
],
"author": "",
"private": false,
"scripts": { "scripts": {
"dev": "cross-env NODE_ENV=development nodemon server/index.js --watch server", "dev": "cross-env NODE_ENV=development nodemon server/index.js --watch server",
"dev:styleguide": "cross-env STYLEGUIDE_DEV=true yarn dev", "dev:styleguide": "cross-env STYLEGUIDE_DEV=true yarn dev",
@ -32,7 +36,7 @@
} }
}, },
"dependencies": { "dependencies": {
"@human-connection/styleguide": "0.5.16", "@human-connection/styleguide": "0.5.17",
"@nuxtjs/apollo": "4.0.0-rc4", "@nuxtjs/apollo": "4.0.0-rc4",
"@nuxtjs/axios": "~5.4.1", "@nuxtjs/axios": "~5.4.1",
"@nuxtjs/dotenv": "~1.3.0", "@nuxtjs/dotenv": "~1.3.0",

View File

@ -763,10 +763,10 @@
resolved "https://registry.yarnpkg.com/@csstools/convert-colors/-/convert-colors-1.4.0.tgz#ad495dc41b12e75d588c6db8b9834f08fa131eb7" resolved "https://registry.yarnpkg.com/@csstools/convert-colors/-/convert-colors-1.4.0.tgz#ad495dc41b12e75d588c6db8b9834f08fa131eb7"
integrity sha512-5a6wqoJV/xEdbRNKVo6I4hO3VjyDq//8q2f9I6PBAvMesJHFauXDorcNCsr9RzvsZnaWi5NYCcfyqP1QeFHFbw== integrity sha512-5a6wqoJV/xEdbRNKVo6I4hO3VjyDq//8q2f9I6PBAvMesJHFauXDorcNCsr9RzvsZnaWi5NYCcfyqP1QeFHFbw==
"@human-connection/styleguide@0.5.16": "@human-connection/styleguide@0.5.17":
version "0.5.16" version "0.5.17"
resolved "https://registry.yarnpkg.com/@human-connection/styleguide/-/styleguide-0.5.16.tgz#442e89280b1a3c51c3ed5904d90b4eced957a40b" resolved "https://registry.yarnpkg.com/@human-connection/styleguide/-/styleguide-0.5.17.tgz#99816579616c8d5be6c66ee86c39cb6c4e694878"
integrity sha512-pER3I1BABX9rC25EUiDPSDNNF40dIQBVPBbbgLHzGBURv43LUSoX/5GHzIpy7a6qnX0LDOop3v7CPF1IfqCt+Q== integrity sha512-Qlo29eOi97lHls40Ms1hbGC29Aoz/W6BLoX/no5TQgHlP4qm+OK7Ra75g0sbj3a2x1Q4mZthUDWcqtjTYf6brw==
dependencies: dependencies:
vue "^2.6.6" vue "^2.6.6"