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
a39ee17c
authored
Jan 03, 2017
by
Arturo Montejo Ráez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fixed error in subscribeToRoom
parent
98fe2429
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
4 deletions
sails/src/api/controllers/StudentController.js
sails/src/api/hooks/rooms.js
sails/src/api/controllers/StudentController.js
View file @
a39ee17c
...
@@ -60,12 +60,15 @@ module.exports = {
...
@@ -60,12 +60,15 @@ module.exports = {
if
(
student
)
{
if
(
student
)
{
if
(
bcrypt
.
compareSync
(
req
.
body
.
password
,
student
.
password
))
{
if
(
bcrypt
.
compareSync
(
req
.
body
.
password
,
student
.
password
))
{
student
.
isStudent
=
true
;
student
.
isStudent
=
true
;
if
(
!
student
.
license
||
!
student
.
license
[
0
]
||
student
.
license
[
0
].
hasExpired
()
)
{
if
(
!
student
.
license
||
!
student
.
license
[
0
])
{
sails
.
log
.
error
(
`Tried to login with non valid license
${
req
.
body
.
username
}
`
);
sails
.
log
.
error
(
`Tried to login with non valid license
${
req
.
body
.
username
}
`
);
return
res
.
unauthorized
(
"Student has an invalid license"
);
}
else
}
else
student
=
student
.
toObject
();
// to enable overwrite license field
student
=
student
.
toObject
();
// to enable overwrite license field
student
.
license
=
student
.
license
[
0
];
student
.
license
=
student
.
license
[
0
];
if
(
student
.
license
[
0
].
hasExpired
())
student
.
license
.
expired
=
true
;
else
student
.
license
.
expired
=
false
;
return
res
.
ok
({
return
res
.
ok
({
user
:
student
,
user
:
student
,
token
:
sailsTokenAuth
.
issueToken
(
student
,
sails
.
config
.
jwt
.
expiresInMinutes
),
token
:
sailsTokenAuth
.
issueToken
(
student
,
sails
.
config
.
jwt
.
expiresInMinutes
),
...
...
sails/src/api/hooks/rooms.js
View file @
a39ee17c
...
@@ -55,8 +55,11 @@ module.exports = function roomsHook (sails) {
...
@@ -55,8 +55,11 @@ module.exports = function roomsHook (sails) {
var
socket_id
=
sails
.
sockets
.
getId
(
socket
);
var
socket_id
=
sails
.
sockets
.
getId
(
socket
);
// append to socketRooms
// append to socketRooms
socketRooms
[
socket_id
]
=
socketRooms
[
socket_id
]
?
[
socketRooms
[
socket_id
],
room
]
:
[
room
];
if
(
!
socketRooms
[
socket_id
])
socketRooms
[
socket_id
]
=
[
room
];
else
socketRooms
[
socket_id
].
push
(
room
);
// broadcast data
// broadcast data
sails
.
hooks
.
events
.
broadcastEvent
(
sails
.
hooks
.
events
.
broadcastEvent
(
...
...
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