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
054e9e17
authored
Feb 08, 2017
by
Arturo Montejo Ráez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
cancel button in supervisor signin
parent
1f15a6e1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
55 additions
and
49 deletions
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/assets/scripts/modules/login/views/signin.html
sails/src/config/locales/en-gb.json
sails/src/api/controllers/SupervisorController.js
View file @
054e9e17
...
@@ -150,14 +150,15 @@ module.exports = {
...
@@ -150,14 +150,15 @@ module.exports = {
delete
supervisor
.
password
;
delete
supervisor
.
password
;
supervisor
.
save
();
supervisor
.
save
();
// an email has to be sent to office administrators
if
(
token
.
role
==
'tutor_office'
||
token
.
role
===
'therapist_office'
)
{
if
(
token
.
role
==
'tutor_office'
||
token
.
role
===
'therapist_office'
)
{
Office
.
findOne
(
token
.
id_off
)
Office
.
findOne
(
token
.
id_off
)
.
populate
(
'admin'
)
.
then
((
off
)
=>
{
.
then
((
off
)
=>
{
if
(
!
off
)
if
(
!
off
)
return
res
.
serverError
(
"Office not found: "
+
err
)
return
res
.
serverError
(
"Office not found: "
+
err
)
// an email has to be sent to office administrators
var
message
=
sails
.
__
({
var
message
=
sails
.
__
({
phrase
:
token
.
role
+
'_request'
,
phrase
:
token
.
role
+
'_request'
,
locale
:
supervisor
.
lang
locale
:
supervisor
.
lang
...
@@ -165,38 +166,29 @@ module.exports = {
...
@@ -165,38 +166,29 @@ module.exports = {
mailService
.
mailer
()
mailService
.
mailer
()
.
send
({
.
send
({
to
:
params
.
email
,
to
:
admin
.
email
,
text
:
message
text
:
message
})
})
.
then
(()
=>
{})
.
then
(()
=>
{})
.
catch
((
err
)
=>
{});
.
catch
((
err
)
=>
{});
return
res
.
view
(
'accountActivated'
,
{
welcome_msg1
:
sails
.
__
({
phrase
:
'welcome_msg1'
,
locale
:
supervisor
.
lang
},
{
name
:
supervisor
.
name
}),
welcome_msg2
:
sails
.
__
({
phrase
:
'welcome_msg2'
,
locale
:
supervisor
.
lang
},
{
login_url
:
'https://'
+
req
.
headers
.
host
+
'/app'
})
});
})
})
.
catch
((
err
)
=>
{
.
catch
((
err
)
=>
{
return
res
.
serverError
(
"Office not found: "
+
err
);
return
res
.
serverError
(
"Office not found: "
+
err
);
});
});
}
else
{
// role is with no office, just return message
return
res
.
view
(
'accountActivated'
,
{
welcome_msg1
:
sails
.
__
({
phrase
:
'welcome_msg1'
,
locale
:
supervisor
.
lang
},
{
name
:
supervisor
.
name
}),
welcome_msg2
:
sails
.
__
({
phrase
:
'welcome_msg2'
,
locale
:
supervisor
.
lang
},
{
login_url
:
'https://'
+
req
.
headers
.
host
+
'/app'
})
});
}
}
// welcome message is returned
return
res
.
view
(
'accountActivated'
,
{
welcome_msg1
:
sails
.
__
({
phrase
:
'welcome_msg1'
,
locale
:
supervisor
.
lang
},
{
name
:
supervisor
.
name
}),
welcome_msg2
:
sails
.
__
({
phrase
:
'welcome_msg2'
,
locale
:
supervisor
.
lang
},
{
login_url
:
'https://'
+
req
.
headers
.
host
+
'/app'
})
});
})
})
.
catch
(
function
(
err
)
{
.
catch
(
function
(
err
)
{
return
res
.
serverError
(
"Error when activating account "
+
err
);
return
res
.
serverError
(
"Error when activating account "
+
err
);
...
@@ -265,13 +257,23 @@ module.exports = {
...
@@ -265,13 +257,23 @@ module.exports = {
*/
*/
create
:
function
(
req
,
res
)
{
create
:
function
(
req
,
res
)
{
var
params
=
req
.
params
.
all
();
var
params
=
req
.
params
.
all
();
var
supervisor
;
// Send email confirmation
function
sendConfirmationMail
(
cb
)
{
function
sendConfirmationMail
(
cb
)
{
/* Send email confirmation */
var
token
=
sailsTokenAuth
.
issueToken
({
id_sup
:
supervisor
.
id
,
role
:
params
.
role
,
id_off
:
params
.
id_off
,
},
60
*
24
*
7
);
// expires in 1 week
var
message
=
sails
.
__
({
var
message
=
sails
.
__
({
phrase
:
'signin_mail'
,
phrase
:
'signin_mail'
,
locale
:
params
.
lang
||
'es-es'
locale
:
params
.
lang
||
'es-es'
})
+
'https://'
+
req
.
headers
.
host
+
'/sup/activate/'
+
token
;
// expires in 1 week
})
+
'https://'
+
req
.
headers
.
host
+
'/sup/activate/'
+
token
;
// expires in 1 week
sails
.
log
.
debug
(
"Sending activation email: \n"
+
message
);
sails
.
log
.
debug
(
"Sending activation email: \n"
+
message
);
mailService
.
mailer
()
mailService
.
mailer
()
...
@@ -288,11 +290,6 @@ module.exports = {
...
@@ -288,11 +290,6 @@ module.exports = {
if
(
!
params
.
name
||
!
params
.
surname
||
!
params
.
gender
||
!
params
.
password
||
!
params
.
email
)
if
(
!
params
.
name
||
!
params
.
surname
||
!
params
.
gender
||
!
params
.
password
||
!
params
.
email
)
res
.
badRequest
(
"Invalid params"
);
res
.
badRequest
(
"Invalid params"
);
var
token
=
sailsTokenAuth
.
issueToken
({
id_sup
:
supervisor
.
id
,
role
:
params
.
role
,
id_off
:
params
.
id_off
,
},
60
*
24
*
7
);
// expires in 1 week
Supervisor
.
create
({
Supervisor
.
create
({
name
:
params
.
name
,
name
:
params
.
name
,
...
@@ -301,18 +298,21 @@ module.exports = {
...
@@ -301,18 +298,21 @@ module.exports = {
password
:
params
.
password
,
password
:
params
.
password
,
email
:
params
.
email
,
email
:
params
.
email
,
pic
:
sails
.
config
.
pictogram
.
paths
.
defaultAvatarFileName
,
pic
:
sails
.
config
.
pictogram
.
paths
.
defaultAvatarFileName
,
address
:
params
.
address
||
null
,
address
:
params
.
address
||
''
,
postal_code
:
params
.
postal_code
||
''
,
country
:
params
.
country
||
null
,
country
:
params
.
country
||
null
,
phone
:
params
.
phone
||
null
,
phone
:
params
.
phone
||
''
,
lang
:
params
.
lang
||
null
,
lang
:
params
.
lang
||
'es-es'
,
ttsEngine
:
params
.
ttsEngine
||
null
,
ttsEngine
:
params
.
ttsEngine
||
null
,
id_off
:
params
.
id_off
||
null
id_off
:
params
.
id_off
||
null
})
})
.
then
(
function
(
sup
ervisor
)
{
.
then
(
function
(
sup
)
{
if
(
!
sup
ervisor
)
if
(
!
sup
)
res
.
serverError
(
"Supervisor created but returned null"
);
res
.
serverError
(
"Supervisor created but returned null"
);
supervisor
=
sup
;
if
(
params
.
role
===
'therapist_office'
||
params
.
role
===
'tutor_office'
)
{
if
(
params
.
role
===
'therapist_office'
||
params
.
role
===
'tutor_office'
)
{
sendConfirmationMail
((
err
)
=>
{
sendConfirmationMail
((
err
)
=>
{
if
(
err
)
throw
err
;
if
(
err
)
throw
err
;
...
...
sails/src/api/models/Office.js
View file @
054e9e17
...
@@ -75,16 +75,17 @@ module.exports = {
...
@@ -75,16 +75,17 @@ module.exports = {
type
:
"integer"
type
:
"integer"
},
},
admin
:
{
admin
:
{
model
:
'supervisor'
,
columnName
:
'admin'
,
required
:
false
required
:
true
,
//type: 'integer'
type
:
'integer'
,
model
:
'Supervisor'
},
},
// Relación con Teacher. [1 Office to N Teacher]
// Relación con Teacher. [1 Office to N Teacher]
supervisors
:
{
supervisors
:
{
collection
:
"Supervisor"
,
collection
:
"Supervisor"
,
via
:
'office'
via
:
'office'
},
},
// Relación con Student. [1 Office to N Student]
// Relación con Student. [1 Office to N Student]
students
:
{
students
:
{
collection
:
"Student"
,
collection
:
"Student"
,
via
:
'office'
via
:
'office'
...
...
sails/src/api/models/Supervisor.js
View file @
054e9e17
...
@@ -52,6 +52,10 @@ module.exports = {
...
@@ -52,6 +52,10 @@ module.exports = {
type
:
"string"
,
type
:
"string"
,
size
:
180
size
:
180
},
},
postal_code
:
{
type
:
"string"
,
size
:
10
},
country
:
{
country
:
{
type
:
"string"
,
type
:
"string"
,
size
:
2
size
:
2
...
...
sails/src/assets/scripts/modules/login/controllers/signin.js
View file @
054e9e17
...
@@ -101,18 +101,18 @@ function SignInCtrl($scope,
...
@@ -101,18 +101,18 @@ function SignInCtrl($scope,
$scope
.
showdialog
=
true
;
$scope
.
showdialog
=
true
;
if
(
$scope
.
formdata
.
office_idx
!=
-
1
)
{
if
(
$scope
.
formdata
.
office_idx
!=
-
1
)
{
$scope
.
formdata
.
id_off
=
$scope
.
offices
[
$scope
.
office_idx
].
id
;
$scope
.
formdata
.
id_off
=
$scope
.
offices
[
$scope
.
formdata
.
office_idx
].
id
;
delete
$scope
.
formdata
.
office_idx
;
delete
$scope
.
formdata
.
office_idx
;
}
}
if
(
$scope
.
formdata
.
role
===
'tutor_nooffice'
)
{
if
(
$scope
.
formdata
.
role
===
'tutor_nooffice'
)
{
$scope
.
formdata
.
office
.
name
:
$scope
.
formdata
.
name
+
" "
+
$scope
.
formdata
.
surname
,
$scope
.
formdata
.
office
.
name
=
$scope
.
formdata
.
name
+
" "
+
$scope
.
formdata
.
surname
;
$scope
.
formdata
.
office
.
address
:
$scope
.
formdata
.
address
,
$scope
.
formdata
.
office
.
address
=
$scope
.
formdata
.
address
;
$scope
.
formdata
.
office
.
postal_code
:
$scope
.
formdata
.
postal_code
,
$scope
.
formdata
.
office
.
postal_code
=
$scope
.
formdata
.
postal_code
;
$scope
.
formdata
.
office
.
country
:
$scope
.
formdata
.
country
,
$scope
.
formdata
.
office
.
country
=
$scope
.
formdata
.
country
;
$scope
.
formdata
.
office
.
contact_person
:
$scope
.
formdata
.
name
+
" "
+
$scope
.
formdata
.
surname
,
$scope
.
formdata
.
office
.
contact_person
=
$scope
.
formdata
.
name
+
" "
+
$scope
.
formdata
.
surname
;
$scope
.
formdata
.
office
.
phone
:
$scope
.
formdata
.
phone
,
$scope
.
formdata
.
office
.
phone
=
$scope
.
formdata
.
phone
;
$scope
.
formdata
.
office
.
email
:
$scope
.
formdata
.
email
$scope
.
formdata
.
office
.
email
=
$scope
.
formdata
.
email
;
}
}
$http
$http
...
...
sails/src/assets/scripts/modules/login/views/signin.html
View file @
054e9e17
...
@@ -231,7 +231,7 @@
...
@@ -231,7 +231,7 @@
<legend
translate
>
office_center
</legend>
<legend
translate
>
office_center
</legend>
<select
class=
"form-control"
ng-model=
"formdata.office_idx"
ng-required=
"formdata.role == 'therapist_office' || formdata.role == 'tutor_office'"
>
<select
class=
"form-control"
ng-model=
"formdata.office_idx"
ng-required=
"formdata.role == 'therapist_office' || formdata.role == 'tutor_office'"
>
<option
selected
disabled
hidden
value=
"-1"
>
{{ 'select_office' | translate }}
</option>
<option
selected
disabled
hidden
value=
"-1"
>
{{ 'select_office' | translate }}
</option>
<option
ng-repeat=
"office in offices | orderBy: 'name' track by $index"
value=
"$index"
>
{{ office.name }}
</option>
<option
ng-repeat=
"office in offices | orderBy: 'name' track by $index"
ng-value=
"$index"
>
{{ office.name }} {{$index}} {{office.id}}
</option>
</select>
</select>
</div>
</div>
...
@@ -247,6 +247,7 @@
...
@@ -247,6 +247,7 @@
</div>
</div>
<p
class=
"text-center"
>
<p
class=
"text-center"
>
<a
href=
"/app/#/login"
class=
"btn btn-default"
translate
>
cancel
</a>
<button
type=
"submit"
class=
"btn btn-primary"
ng-disabled=
"signInForm.$invalid"
translate
>
create_account
</button>
<button
type=
"submit"
class=
"btn btn-primary"
ng-disabled=
"signInForm.$invalid"
translate
>
create_account
</button>
</p>
</p>
...
...
sails/src/config/locales/en-gb.json
View file @
054e9e17
...
@@ -7,5 +7,5 @@
...
@@ -7,5 +7,5 @@
"therapist_office_request"
:
"{{ name }}, with email {{ email }}, is requesting to be linked as therapist to any of your students."
,
"therapist_office_request"
:
"{{ name }}, with email {{ email }}, is requesting to be linked as therapist to any of your students."
,
"tutor_office_request"
:
"{{ name }}, with email {{ email }}, is requesting to be linked as tutor/father/mother to any of your students."
,
"tutor_office_request"
:
"{{ name }}, with email {{ email }}, is requesting to be linked as tutor/father/mother to any of your students."
,
"welcome_msg1"
:
"Welcome to Pictogram, {{ name }}!"
,
"welcome_msg1"
:
"Welcome to Pictogram, {{ name }}!"
,
"welcome_msg2"
:
"Your account is now active
, so y
ou can proceed to <a href=
\"
{{ login_url }}
\"
>login</a>."
"welcome_msg2"
:
"Your account is now active
. Y
ou can proceed to <a href=
\"
{{ login_url }}
\"
>login</a>."
}
}
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