Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ACS
Public
VILLASframework
VILLASweb
Commits
c9ad98bc
Commit
c9ad98bc
authored
Oct 29, 2019
by
Laura Fuentes Grau
Browse files
improved
#197
user will be notified if the confirmed password doesn't match
parent
14ff56df
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/common/array-store.js
View file @
c9ad98bc
...
...
@@ -22,6 +22,7 @@
import
{
ReduceStore
}
from
'
flux/utils
'
;
import
AppDispatcher
from
'
./app-dispatcher
'
;
import
NotificationsDataManager
from
'
../common/data-managers/notifications-data-manager
'
;
class
ArrayStore
extends
ReduceStore
{
constructor
(
type
,
dataManager
)
{
...
...
@@ -84,9 +85,18 @@ class ArrayStore extends ReduceStore {
}
case
this
.
type
+
'
/load-error
'
:
// TODO: Add error message
return
state
;
if
(
action
.
error
&&
!
action
.
error
.
handled
&&
action
.
error
.
response
)
{
const
USER_LOAD_ERROR_NOTIFICATION
=
{
title
:
'
Failed to load
'
,
message
:
action
.
error
.
response
.
body
.
message
,
level
:
'
error
'
};
NotificationsDataManager
.
addNotification
(
USER_LOAD_ERROR_NOTIFICATION
);
}
return
super
.
reduce
(
state
,
action
);
case
this
.
type
+
'
/start-add
'
:
this
.
dataManager
.
add
(
action
.
data
,
action
.
token
);
return
state
;
...
...
@@ -95,8 +105,9 @@ class ArrayStore extends ReduceStore {
return
this
.
updateElements
(
state
,
[
action
.
data
]);
case
this
.
type
+
'
/add-error
'
:
// TODO: Add error message
return
state
;
return
state
;
case
this
.
type
+
'
/start-remove
'
:
this
.
dataManager
.
remove
(
action
.
data
,
action
.
token
);
...
...
@@ -108,9 +119,18 @@ class ArrayStore extends ReduceStore {
});
case
this
.
type
+
'
/remove-error
'
:
// TODO: Add error message
return
state
;
if
(
action
.
error
&&
!
action
.
error
.
handled
&&
action
.
error
.
response
)
{
const
USER_REMOVE_ERROR_NOTIFICATION
=
{
title
:
'
Failed to add remove
'
,
message
:
action
.
error
.
response
.
body
.
message
,
level
:
'
error
'
};
NotificationsDataManager
.
addNotification
(
USER_REMOVE_ERROR_NOTIFICATION
);
}
return
super
.
reduce
(
state
,
action
);
case
this
.
type
+
'
/start-edit
'
:
this
.
dataManager
.
update
(
action
.
data
,
action
.
token
);
return
state
;
...
...
@@ -122,10 +142,18 @@ class ArrayStore extends ReduceStore {
case
this
.
type
+
'
/edited
'
:
return
this
.
updateElements
(
state
,
[
action
.
data
]);
case
this
.
type
+
'
/edit-error
'
:
// TODO: Add error message
case
this
.
type
+
'
/confirm-pw-doesnt-match
'
:
const
USER_PW_ERROR_NOTIFICATION
=
{
title
:
'
The new password does not match
'
,
message
:
'
Try again
'
,
level
:
'
error
'
};
NotificationsDataManager
.
addNotification
(
USER_PW_ERROR_NOTIFICATION
);
return
state
;
case
this
.
type
+
'
/edit-error
'
:
return
state
;
default
:
return
state
;
}
...
...
src/user/edit-user.js
View file @
c9ad98bc
...
...
@@ -37,7 +37,8 @@ class EditUserDialog extends React.Component {
id
:
''
,
password
:
''
,
active
:
''
,
confirmpassword
:
''
confirmpassword
:
''
,
oldPassword
:
''
}
}
...
...
@@ -61,6 +62,7 @@ class EditUserDialog extends React.Component {
var
pw
=
true
;
var
active
=
true
;
var
confirmpassword
=
true
;
var
oldPW
=
true
;
if
(
this
.
state
.
username
===
''
)
{
...
...
@@ -87,9 +89,12 @@ class EditUserDialog extends React.Component {
confirmpassword
=
false
;
}
if
(
this
.
state
.
oldPassword
===
''
){
oldPW
=
false
;
}
// form is valid if any of the fields contain somethig
this
.
valid
=
username
||
role
||
mail
||
pw
||
active
||
confirmpassword
;
this
.
valid
=
username
||
role
||
mail
||
pw
||
active
||
confirmpassword
||
oldPW
;
}
...
...
@@ -115,6 +120,10 @@ class EditUserDialog extends React.Component {
<
FormLabel
>
E
-
mail
<
/FormLabel
>
<
FormControl
type
=
"
text
"
placeholder
=
"
Enter e-mail
"
value
=
{
this
.
state
.
mail
}
onChange
=
{(
e
)
=>
this
.
handleChange
(
e
)}
/
>
<
/FormGroup
>
<
FormGroup
as
=
{
Col
}
controlId
=
"
oldPassword
"
>
<
FormLabel
>
Old
Password
<
/FormLabel
>
<
FormControl
type
=
"
password
"
placeholder
=
"
Enter current password
"
value
=
{
this
.
state
.
oldPassword
}
onChange
=
{(
e
)
=>
this
.
handleChange
(
e
)}
/
>
<
/FormGroup
>
<
FormGroup
as
=
{
Col
}
controlId
=
"
password
"
>
<
FormLabel
>
Password
<
/FormLabel
>
<
FormControl
type
=
"
password
"
placeholder
=
"
Enter password
"
value
=
{
this
.
state
.
password
}
onChange
=
{(
e
)
=>
this
.
handleChange
(
e
)}
/
>
...
...
src/user/user.js
View file @
c9ad98bc
...
...
@@ -84,7 +84,11 @@ class User extends Component {
}
else
{
console
.
log
(
"
error: not the same password
"
);
AppDispatcher
.
dispatch
({
type
:
'
users/confirm-pw-doesnt-match
'
,
data
:
data
,
token
:
this
.
state
.
token
});
}
}
...
...
@@ -120,6 +124,8 @@ class User extends Component {
<
Col
xs
=
{
3
}
>
Role
:
<
/Col
>
<
Col
xs
=
{
3
}
>
{
this
.
state
.
user
.
role
}
<
/Col
>
<
/Row
>
<
Button
onClick
=
{()
=>
this
.
setState
({
editModal
:
true
})}
><
Icon
icon
=
'
edit
'
/>
Edit
<
/Button
>
<
EditOwnUserDialog
show
=
{
this
.
state
.
editModal
}
onClose
=
{(
data
)
=>
this
.
closeEditModal
(
data
)}
user
=
{
this
.
state
.
modalData
}
/
>
...
...
src/user/users-store.js
View file @
c9ad98bc
...
...
@@ -55,7 +55,7 @@ class UsersStore extends ArrayStore {
NotificationsDataManager
.
addNotification
(
USER_EDIT_ERROR_NOTIFICATION
);
}
return
super
.
reduce
(
state
,
action
);
return
super
.
reduce
(
state
,
action
);
default
:
return
super
.
reduce
(
state
,
action
);
...
...
src/user/users.js
View file @
c9ad98bc
...
...
@@ -103,7 +103,11 @@ class Users extends Component {
}
else
{
console
.
log
(
"
error: not the same password
"
);
AppDispatcher
.
dispatch
({
type
:
'
users/confirm-pw-doesnt-match
'
,
data
:
data
,
token
:
this
.
state
.
token
});
}
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment