Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
X
xpub-faraday
Manage
Activity
Members
Labels
Plan
Issues
2
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Container Registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
xpub
xpub-faraday
Commits
e4872bcc
Commit
e4872bcc
authored
6 years ago
by
Tania Fecheta
Browse files
Options
Downloads
Patches
Plain Diff
feat(passwordConfirmation): make the text red in case of error - wip
parent
98604e91
No related branches found
No related tags found
3 merge requests
!196
S25 - EiC submit revision
,
!189
S25
,
!183
Hin 961 strong password
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
packages/component-faraday-ui/src/PasswordConfirmation.js
+31
-6
31 additions, 6 deletions
packages/component-faraday-ui/src/PasswordConfirmation.js
packages/components-faraday/src/components/utils.js
+7
-1
7 additions, 1 deletion
packages/components-faraday/src/components/utils.js
with
38 additions
and
7 deletions
packages/component-faraday-ui/src/PasswordConfirmation.js
+
31
−
6
View file @
e4872bcc
import
React
,
{
Fragment
}
from
'
react
'
import
{
required
}
from
'
xpub-validators
'
import
{
connect
}
from
'
react-redux
'
import
{
getFormValues
}
from
'
redux-form
'
import
{
getFormValues
,
getFormSyncErrors
}
from
'
redux-form
'
import
{
ValidatedField
,
TextField
}
from
'
@pubsweet/ui
'
import
{
th
}
from
'
@pubsweet/ui-toolkit
'
import
{
Row
,
Item
,
Label
,
IconButton
}
from
'
pubsweet-component-faraday-ui
'
import
styled
from
'
styled-components
'
import
styled
,
{
css
}
from
'
styled-components
'
import
{
get
}
from
'
lodash
'
const
PasswordField
=
input
=>
<
TextField
{...
input
}
type
=
"
password
"
/>
...
...
@@ -26,7 +27,10 @@ const atLeastOnePunctuation = value => {
const
punctuationRegex
=
new
RegExp
(
/
([
,'!@#$%^&*(){}[
\]
<>?
/\\
|.:;_-
])
+/
)
return
punctuationRegex
.
test
(
value
)
}
const
PasswordConfirmation
=
({
formValues
:
{
password
=
''
}
})
=>
(
const
PasswordConfirmation
=
({
formValues
:
{
password
=
''
},
formErrors
=
{},
})
=>
(
<
Fragment
>
<
Row
mb
=
{
2
}
>
<
Item
data
-
test
-
id
=
"
sign-up-password
"
vertical
>
...
...
@@ -55,7 +59,12 @@ const PasswordConfirmation = ({ formValues: { password = '' } }) => (
<
RulesTitle
>
The
password
must
contain
:
<
/RulesTitle
>
<
/div
>
<
Rules
>
<
Rule
fulfilled
=
{
minLength
(
password
,
6
)}
>
at
least
6
characters
<
/Rule
>
<
Rule
error
=
{
get
(
formErrors
,
'
minLength
'
,
false
)}
fulfilled
=
{
minLength
(
password
,
6
)}
>
at
least
6
characters
<
/Rule
>
<
Rule
fulfilled
=
{
atLeastOneUppercase
(
password
)}
>
at
least
1
uppercase
character
(
A
-
Z
)
<
/Rule
>
...
...
@@ -76,6 +85,7 @@ const PasswordConfirmation = ({ formValues: { password = '' } }) => (
export
default
connect
(
state
=>
({
formValues
:
getFormValues
(
'
signUpInvitation
'
)(
state
),
formErrors
:
getFormSyncErrors
(
'
signUpInvitation
'
)(
state
),
}))(
PasswordConfirmation
)
const
RulesTitle
=
styled
.
p
`
...
...
@@ -105,8 +115,23 @@ const Rules = styled.div`
letter-spacing: normal;
color: var(--black);
`
const
ruleHelper
=
props
=>
{
const
textDecoration
=
props
.
fulfilled
?
'
line-through
'
:
'
none
'
let
textColor
=
'
inherit
'
if
(
props
.
error
)
{
textColor
=
'
red
'
}
else
if
(
props
.
fulfilled
)
{
textColor
=
'
green
'
}
return
css
`
text-decoration:
${
textDecoration
}
;
color:
${
textColor
}
;
`
}
const
Rule
=
styled
.
p
`
margin: 0px;
text-decoration:
${
props
=>
(
props
.
fulfilled
?
'
line-through
'
:
'
none
'
)}
;
color:
${
props
=>
(
props
.
fulfilled
?
th
(
'
colorPrimary
'
)
:
'
inherit
'
)}
;
${
ruleHelper
}
;
`
This diff is collapsed.
Click to expand it.
packages/components-faraday/src/components/utils.js
+
7
−
1
View file @
e4872bcc
...
...
@@ -103,7 +103,13 @@ export const redirectToError = redirectFn => err => {
}
export
const
passwordValidator
=
values
=>
{
const
errors
=
{}
const
errors
=
{
minLength
:
false
,
}
const
minLength
=
(
value
,
min
)
=>
!!
(
value
&&
value
.
length
>
min
)
if
(
minLength
(
values
.
password
,
6
)
===
false
)
{
errors
.
minLength
=
true
}
if
(
!
values
.
password
)
{
errors
.
password
=
'
Required
'
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment