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
e6df2b6c
authored
May 24, 2017
by
Arturo Montejo Ráez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
better handling of errors in supervisor signin
parent
8cd04f26
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
80 deletions
sails/src/CHANGES.md
sails/src/api/controllers/SupervisorController.js
sails/src/api/models/Office.js
sails/src/api/models/Supervisor.js
sails/src/assets/scripts/modules/login/controllers/signin.js
sails/src/CHANGES.md
View file @
e6df2b6c
...
...
@@ -2,16 +2,8 @@
Changes to be performed manually in servers to upgrade
## AngularJS
(already done in dev & pre)
-
angular-re-captcha has been replaced by angular-recaptcha, so bower has to be run
-
reinstall ui-bootstrap
-
replace angular-file-upload by ng-file-upload
`bower install`
## Database
-
Delete active column from scene table (deleted from
`already done in dev`
sql
`create scene table`
statement)
`alter table scene drop active;`
...
...
@@ -54,29 +46,3 @@ Changes to be performed manually in servers to upgrade
-
Reload enrolments trigger
`source /vagrant/roles/database/files/triggers-enrolments-integrity-constraints.sql`
(already done in dev & pre)
-
add new column to license:
`alter table license add column creator varchar(40) DEFAULT NULL;`
-
add arasaac to source table
`INSERT INTO `
source
` (`
id
`, `
name
`, `
description
`) VALUES (3, 'Arasaac', 'Arasaac pictograms collection');`
-
alter table supervisor add arasaac license:
`ALTER TABLE supervisor ADD COLUMN arasaac_license BOOLEAN DEFAULT FALSE;`
-
load arasaac.sql into MySQL
-
load pictocat_tree_populate.sql
`source /vagrant/roles/database/files/pictocat_tree_populate.sql;`
-
reload trigers-enrolments-integrity-constraints.sql
-
alter table supervisor to add postal_code:
`alter table supervisor add column `
postal_code
` char(10) COLLATE utf8_unicode_ci NOT NULL;`
-
alter table office to add postal_code:
`alter table office add column `
postal_code
` char(10) COLLATE utf8_unicode_ci NOT NULL;`
-
remove max_students and current_students columns from offices:
`alter table office drop column max_students;`
`alter table office drop column current_students;`
-
copy postal_code value from office to its supervisors
`update supervisor as sup inner join office as off on off.id = sup.id_off set sup.postal_code = off.postal_code;`
-
alter table office
`alter table office modify logo_url varchar(240) default null;`
sails/src/api/controllers/SupervisorController.js
View file @
e6df2b6c
...
...
@@ -330,7 +330,7 @@ module.exports = {
email
:
params
.
email
,
pic
:
sails
.
config
.
pictogram
.
paths
.
defaultAvatarFileName
,
address
:
params
.
address
||
''
,
postal
C
ode
:
params
.
postalCode
||
''
,
postal
_c
ode
:
params
.
postalCode
||
''
,
country
:
params
.
country
||
''
,
phone
:
params
.
phone
||
''
,
lang
:
params
.
lang
||
'es-es'
,
...
...
@@ -338,6 +338,7 @@ module.exports = {
if
(
params
.
id_off
)
supData
.
id_off
=
params
.
id_off
;
console
.
log
(
JSON
.
stringify
(
supData
));
Supervisor
.
create
(
supData
)
.
then
(
function
(
sup
)
{
...
...
@@ -367,13 +368,15 @@ module.exports = {
off
.
admin
=
sup
.
id
;
off
.
save
();
supervisor
=
sup
;
supervisor
=
sup
;
sendConfirmationMail
((
err
)
=>
{
if
(
err
)
throw
err
;
if
(
err
)
return
res
.
serverError
(
"Confirmation mail could not be sent: "
+
err
)
;
return
res
.
ok
();
});
})
.
catch
(
err
=>
{
throw
err
});
.
catch
((
err
)
=>
{
return
res
.
serverError
(
"Supervisor could not be created: "
+
err
);
});
}
else
return
res
.
badRequest
(
"Invalid role"
);
}).
catch
(
function
(
err
)
{
...
...
@@ -474,37 +477,31 @@ module.exports = {
update
:
function
(
req
,
res
)
{
Supervisor
.
findOne
({
id
:
req
.
params
.
id
})
.
then
(
function
(
supervisor
)
{
if
(
supervisor
)
{
if
(
req
.
body
.
password
)
{
supervisor
.
password
=
req
.
body
.
password
;
}
else
{
delete
supervisor
.
password
;
}
supervisor
.
name
=
req
.
body
.
name
||
supervisor
.
name
;
supervisor
.
surname
=
req
.
body
.
surname
||
supervisor
.
surname
;
supervisor
.
gender
=
req
.
body
.
gender
||
supervisor
.
gender
;
supervisor
.
pic
=
req
.
body
.
pic
||
supervisor
.
pic
;
supervisor
.
address
=
req
.
body
.
address
||
supervisor
.
address
;
supervisor
.
postalCode
=
req
.
body
.
postalCode
||
supervisor
.
postalCode
;
supervisor
.
country
=
req
.
body
.
country
||
supervisor
.
country
;
supervisor
.
email
=
req
.
body
.
email
||
supervisor
.
email
;
supervisor
.
phone
=
req
.
body
.
phone
||
supervisor
.
phone
;
supervisor
.
lang
=
req
.
body
.
lang
||
supervisor
.
lang
;
supervisor
.
ttsEngine
=
req
.
body
.
ttsEngine
||
supervisor
.
ttsEngine
;
supervisor
.
office
=
req
.
body
.
office
||
supervisor
.
office
;
supervisor
.
save
(
function
(
error
)
{
if
(
error
)
{
res
.
serverError
();
}
else
{
res
.
ok
(
supervisor
);
}
});
}
else
{
res
.
notFound
();
}
if
(
!
supervisor
)
return
res
.
notFound
();
if
(
req
.
body
.
password
&&
req
.
body
.
password
.
length
>
0
)
supervisor
.
password
=
req
.
body
.
password
;
else
delete
supervisor
.
password
;
supervisor
.
name
=
req
.
body
.
name
||
supervisor
.
name
;
supervisor
.
surname
=
req
.
body
.
surname
||
supervisor
.
surname
;
supervisor
.
gender
=
req
.
body
.
gender
||
supervisor
.
gender
;
supervisor
.
pic
=
req
.
body
.
pic
||
supervisor
.
pic
;
supervisor
.
address
=
req
.
body
.
address
||
supervisor
.
address
;
supervisor
.
postalCode
=
req
.
body
.
postalCode
||
supervisor
.
postalCode
;
supervisor
.
country
=
req
.
body
.
country
||
supervisor
.
country
;
supervisor
.
email
=
req
.
body
.
email
||
supervisor
.
email
;
supervisor
.
phone
=
req
.
body
.
phone
||
supervisor
.
phone
;
supervisor
.
lang
=
req
.
body
.
lang
||
supervisor
.
lang
;
supervisor
.
ttsEngine
=
req
.
body
.
ttsEngine
||
supervisor
.
ttsEngine
;
supervisor
.
office
=
req
.
body
.
office
||
supervisor
.
office
;
supervisor
.
save
(
function
(
error
)
{
if
(
error
)
throw
error
;
return
res
.
ok
(
supervisor
);
});
})
.
catch
(
function
()
{
re
s
.
serverError
(
);
.
catch
(
function
(
err
)
{
re
turn
res
.
serverError
(
err
);
});
},
...
...
sails/src/api/models/Office.js
View file @
e6df2b6c
...
...
@@ -44,7 +44,7 @@ module.exports = {
lang
:
{
required
:
true
,
type
:
"string"
,
size
:
2
size
:
5
},
contactPerson
:
{
columnName
:
"contact_person"
,
...
...
@@ -88,12 +88,13 @@ module.exports = {
collection
:
"Student"
,
via
:
'office'
},
toJSON
:
function
()
{
var
office
=
this
.
toObject
();
if
(
!
office
.
logoUrl
)
office
.
logoUrl
=
'/app/img/logo_pictogram.png'
;
return
office
;
}
toJSON
:
function
()
{
var
office
=
this
.
toObject
();
if
(
!
office
.
logoUrl
)
office
.
logoUrl
=
'/app/img/logo_pictogram.png'
;
return
office
;
}
},
beforeCreate
:
function
(
attrs
,
next
)
{
...
...
sails/src/api/models/Supervisor.js
View file @
e6df2b6c
...
...
@@ -74,7 +74,7 @@ module.exports = {
lang
:
{
required
:
true
,
type
:
"string"
,
size
:
2
size
:
5
},
ttsEngine
:
{
columnName
:
'tts_engine'
,
...
...
@@ -143,7 +143,7 @@ module.exports = {
//
beforeCreate
:
function
(
attrs
,
next
)
{
var
async
=
require
(
'async'
);
console
.
log
(
"-->\n"
+
JSON
.
stringify
(
attrs
));
async
.
series
(
[
function
(
cb
)
{
...
...
@@ -203,7 +203,8 @@ module.exports = {
var
bcrypt
=
require
(
'bcrypt-nodejs'
);
if
(
attrs
.
password
&&
attrs
.
password
.
length
>
0
)
{
attrs
.
password
=
bcrypt
.
hashSync
(
attrs
.
password
,
bcrypt
.
genSaltSync
());
}
}
else
delete
attrs
.
password
;
cb
();
}
],
...
...
sails/src/assets/scripts/modules/login/controllers/signin.js
View file @
e6df2b6c
...
...
@@ -21,7 +21,7 @@ function SignInCtrl($scope,
name
:
''
,
surname
:
''
,
address
:
''
,
postal
_c
ode
:
''
,
postal
C
ode
:
''
,
country
:
'00'
,
phone
:
''
,
gender
:
'F'
,
...
...
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