Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-jams
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-jams
Commits
ccff0f63
Commit
ccff0f63
authored
4 years ago
by
Larbi Gharib
Browse files
Options
Downloads
Patches
Plain Diff
Username constraints
Change-Id: I7913d9d0a2bf230478720ce402bb28fe31998fb3
parent
b339cfe3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
jams-react-client/src/views/UserProfile/EditCreateUserProfile.js
+19
-16
19 additions, 16 deletions
...act-client/src/views/UserProfile/EditCreateUserProfile.js
with
19 additions
and
16 deletions
jams-react-client/src/views/UserProfile/EditCreateUserProfile.js
+
19
−
16
View file @
ccff0f63
...
...
@@ -186,7 +186,7 @@ export default function EditCreateUserProfile(props) {
const
history
=
useHistory
();
const
[
createUser
,
setCreateUser
]
=
React
.
useState
(
props
.
createUser
);
const
[
copied
,
setCopied
]
=
React
.
useState
(
false
);
const
[
generated
,
setGenerated
]
=
React
.
useState
(
fals
e
);
const
[
generated
,
setGenerated
]
=
React
.
useState
(
tru
e
);
const
[
userExists
,
setUserExists
]
=
React
.
useState
(
false
);
const
[
userName
,
setUserName
]
=
React
.
useState
(
""
);
...
...
@@ -204,10 +204,21 @@ export default function EditCreateUserProfile(props) {
const
[
rotation
,
setRotation
]
=
React
.
useState
(
0
);
const
[
passwordVisible
,
setPasswordVisible
]
=
React
.
useState
(
false
);
const
passwordGenerator
=
()
=>
{
return
generator
.
generate
({
length
:
10
,
uppercase
:
false
,
numbers
:
true
,
symbols
:
true
,
});
};
const
intialyGeneratedPassword
=
passwordGenerator
();
const
initialValues
=
{
username
:
""
,
password
:
""
,
confirmPassword
:
""
,
password
:
intialyGeneratedPassword
,
confirmPassword
:
intialyGeneratedPassword
,
firstName
:
""
,
lastName
:
""
,
email
:
""
,
...
...
@@ -220,15 +231,6 @@ export default function EditCreateUserProfile(props) {
jamiId
:
""
,
};
const
passwordGenerator
=
()
=>
{
return
generator
.
generate
({
length
:
10
,
uppercase
:
false
,
numbers
:
true
,
symbols
:
true
,
});
};
React
.
useEffect
(()
=>
{
console
.
log
(
rotation
);
if
(
!
createUser
)
{
...
...
@@ -368,9 +370,10 @@ export default function EditCreateUserProfile(props) {
const
EditCreateSchema
=
Yup
.
object
().
shape
({
username
:
Yup
.
string
()
.
min
(
2
,
"
Username is too short!
"
)
.
required
(
"
Required!
"
)
.
test
(
"
checkDuplUsername
"
,
"
Username exists!
"
,
function
(
value
)
{
.
min
(
3
,
"
Username must be minimum 3 characters!
"
)
.
max
(
32
,
"
Username must be maximum 32 characters!
"
)
.
required
(
"
Username is required!
"
)
.
test
(
"
checkDuplUsername
"
,
"
Username already taken
"
,
function
(
value
)
{
if
(
createUser
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
data
=
{
...
...
@@ -399,7 +402,7 @@ export default function EditCreateUserProfile(props) {
return
true
;
}
})
.
matches
(
/^
[
a-z
A-Z0-9
]
*$/
,
"
Only alphanumeric characters!
"
),
.
matches
(
/^
[
A-Z
a-z_
][
A-Za-z
0-9
_
]
*$/
,
"
Only alphanumeric characters!
"
),
password
:
createUser
?
Yup
.
string
().
required
(
"
Password is required!
"
)
:
null
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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