Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
yotta
/
pictogram
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
60
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
c2fb874a
authored
Aug 14, 2017
by
Arturo Montejo Ráez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
update of user data after submission
parent
ceb18c42
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
18 deletions
sails/src/api/controllers/SupervisorController.js
sails/src/assets/scripts/modules/supervisor/controllers/setup.js
sails/src/api/controllers/SupervisorController.js
View file @
c2fb874a
...
@@ -67,7 +67,8 @@ module.exports = {
...
@@ -67,7 +67,8 @@ module.exports = {
if
(
!
email
||
!
password
)
if
(
!
email
||
!
password
)
return
res
.
badRequest
(
'Missing parameters'
);
return
res
.
badRequest
(
'Missing parameters'
);
Supervisor
.
findOneByEmail
(
email
).
then
(
function
(
supervisor
)
{
Supervisor
.
findOneByEmail
(
email
)
.
then
(
function
(
supervisor
)
{
if
(
!
supervisor
)
if
(
!
supervisor
)
throw
new
Error
(
"Supervisor not found"
)
throw
new
Error
(
"Supervisor not found"
)
...
@@ -78,10 +79,6 @@ module.exports = {
...
@@ -78,10 +79,6 @@ module.exports = {
if
(
supervisor
.
active
==
0
)
if
(
supervisor
.
active
==
0
)
throw
new
Error
(
"This account has not been activated"
);
throw
new
Error
(
"This account has not been activated"
);
return
(
supervisor
);
}).
then
(
function
(
supervisor
)
{
return
res
.
ok
({
return
res
.
ok
({
user
:
supervisor
,
user
:
supervisor
,
server_time
:
(
new
Date
()).
getTime
(),
server_time
:
(
new
Date
()).
getTime
(),
...
...
sails/src/assets/scripts/modules/supervisor/controllers/setup.js
View file @
c2fb874a
...
@@ -18,13 +18,11 @@ dashboardControllers.controller('SetupCtrl', function SetupCtrl(
...
@@ -18,13 +18,11 @@ dashboardControllers.controller('SetupCtrl', function SetupCtrl(
config
,
config
,
CONSTANTS
)
{
CONSTANTS
)
{
$scope
.
user
=
$rootScope
.
user
;
// Don't show the message at the begining
// Don't show the message at the begining
$scope
.
showmessage
=
false
;
$scope
.
showmessage
=
false
;
// Restore user values from sessionStorage
// Restore user values from sessionStorage
$scope
.
formdata
=
JSON
.
parse
(
$window
.
sessionStorage
.
user
);
;
$scope
.
formdata
=
JSON
.
parse
(
JSON
.
stringify
(
$scope
.
user
))
;
$scope
.
changeImg
=
function
()
{
$scope
.
changeImg
=
function
()
{
...
@@ -77,8 +75,6 @@ dashboardControllers.controller('SetupCtrl', function SetupCtrl(
...
@@ -77,8 +75,6 @@ dashboardControllers.controller('SetupCtrl', function SetupCtrl(
// Form submit
// Form submit
$scope
.
setup
=
function
()
{
$scope
.
setup
=
function
()
{
var
supervisor
;
var
actualEmail
;
if
(
$scope
.
formdata
.
password
&&
$scope
.
formdata
.
password
!==
$scope
.
formdata
.
password_confirm
)
{
if
(
$scope
.
formdata
.
password
&&
$scope
.
formdata
.
password
!==
$scope
.
formdata
.
password_confirm
)
{
ngToast
.
danger
({
content
:
$translate
.
instant
(
'password_match'
)
});
ngToast
.
danger
({
content
:
$translate
.
instant
(
'password_match'
)
});
...
@@ -95,15 +91,13 @@ dashboardControllers.controller('SetupCtrl', function SetupCtrl(
...
@@ -95,15 +91,13 @@ dashboardControllers.controller('SetupCtrl', function SetupCtrl(
return
;
return
;
}
}
supervisor
=
$scope
.
formdata
;
var
supervisor
=
JSON
.
parse
(
JSON
.
stringify
(
$scope
.
formdata
))
;
if
(
supervisor
.
password
&&
supervisor
.
password
.
length
==
0
)
if
(
supervisor
.
password
&&
supervisor
.
password
.
length
==
0
)
delete
supervisor
.
password
;
delete
supervisor
.
password
;
actualEmail
=
JSON
.
parse
(
$window
.
sessionStorage
.
user
).
email
;
// Comprobation for new email
// Comprobation for new email
// If no change, it is deleted from supervisor object
// If no change, it is deleted from supervisor object
if
(
supervisor
.
email
===
actualE
mail
)
{
if
(
supervisor
.
email
===
$scope
.
user
.
e
mail
)
{
delete
supervisor
.
email
;
delete
supervisor
.
email
;
}
}
...
@@ -112,12 +106,9 @@ dashboardControllers.controller('SetupCtrl', function SetupCtrl(
...
@@ -112,12 +106,9 @@ dashboardControllers.controller('SetupCtrl', function SetupCtrl(
$http
.
put
(
config
.
backend
+
'/sup/'
+
supervisor
.
id
,
supervisor
)
$http
.
put
(
config
.
backend
+
'/sup/'
+
supervisor
.
id
,
supervisor
)
.
success
(
function
(
data
)
{
.
success
(
function
(
data
)
{
ngToast
.
success
({
content
:
$translate
.
instant
(
'data_saved'
)
});
delete
data
.
password
;
delete
data
.
password_confirm
;
$scope
.
user
=
JSON
.
parse
(
JSON
.
stringify
(
data
));
$scope
.
user
=
JSON
.
parse
(
JSON
.
stringify
(
data
));
$window
.
sessionStorage
.
user
=
JSON
.
stringify
(
$scope
.
user
);
$window
.
sessionStorage
.
user
=
JSON
.
stringify
(
$scope
.
user
);
ngToast
.
success
({
content
:
$translate
.
instant
(
'data_saved'
)
});
})
})
.
error
(
function
()
{
.
error
(
function
()
{
ngToast
.
danger
({
content
:
$translate
.
instant
(
'data_no_saved'
)
});
ngToast
.
danger
({
content
:
$translate
.
instant
(
'data_no_saved'
)
});
...
...
Write
Preview
Markdown
is supported
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