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
ebc987b4
authored
Apr 19, 2016
by
Pablo Molina
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merged origin/master into master
parents
43f9b70f
66ed4620
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
46 additions
and
32 deletions
sails/src/api/controllers/SupervisorController.js
sails/src/api/models/Supervisor.js
sails/src/assets/app/img/logo_pictogram.png
sails/src/assets/app/modules/login/controllers/signin.js
sails/src/assets/app/modules/login/views/signin.html
sails/src/api/controllers/SupervisorController.js
View file @
ebc987b4
...
@@ -152,6 +152,8 @@ module.exports = {
...
@@ -152,6 +152,8 @@ module.exports = {
//
//
create
:
function
(
req
,
res
)
{
create
:
function
(
req
,
res
)
{
var
params
=
req
.
params
.
all
();
var
params
=
req
.
params
.
all
();
delete
params
.
email_confirm
;
delete
params
.
password_confirm
;
Supervisor
.
create
(
params
).
exec
(
function
(
err
,
created
)
{
Supervisor
.
create
(
params
).
exec
(
function
(
err
,
created
)
{
if
(
err
)
{
if
(
err
)
{
...
@@ -159,10 +161,13 @@ module.exports = {
...
@@ -159,10 +161,13 @@ module.exports = {
return
res
.
json
(
500
,
{
error
:
'User not created'
});
return
res
.
json
(
500
,
{
error
:
'User not created'
});
}
}
if
(
created
)
{
if
(
created
)
{
// Send email confirmation
// TODO: Send email confirmation
console
.
log
(
"sending mail to user"
);
// created.sendMail();
created
.
sendMail
();
return
res
.
json
({
return
res
.
json
({
user
:
created
,
token
:
sailsTokenAuth
.
issueToken
(
created
.
id
)});
user
:
created
,
token
:
sailsTokenAuth
.
issueToken
(
created
.
id
)});
}
else
{
return
res
.
json
(
500
,
{
error
:
'User not created'
});
}
}
});
});
},
},
...
...
sails/src/api/models/Supervisor.js
View file @
ebc987b4
...
@@ -186,31 +186,32 @@ module.exports = {
...
@@ -186,31 +186,32 @@ module.exports = {
//
//
beforeCreate
:
function
(
attrs
,
next
)
{
beforeCreate
:
function
(
attrs
,
next
)
{
//
// We have to encryption AFTER checking user does not exist
// Check that user does not exist
// so... we use async.series to ensure task completion
// NOTE: This is not needed as uniqueness is granted by DB
//
async
.
series
([
function
(
cb
)
{
// check email is new
Supervisor
.
findByEmail
(
attrs
.
email
).
exec
(
function
(
err
,
users
)
{
Supervisor
.
findByEmail
(
attrs
.
email
).
exec
(
function
(
err
,
users
)
{
if
(
err
)
if
(
err
)
return
cb
(
err
);
return
next
(
err
);
if
(
users
.
length
>
0
)
if
(
users
.
length
>
0
)
return
next
(
new
Error
(
'User exists'
));
return
cb
(
new
Error
(
'User exists'
));
cb
();
});
});
},
//
function
(
cb
)
{
// encrypt password
// Encrypt password before insertion
//
var
bcrypt
=
require
(
'bcrypt-nodejs'
);
var
bcrypt
=
require
(
'bcrypt-nodejs'
);
bcrypt
.
genSalt
(
10
,
function
(
err
,
salt
)
{
bcrypt
.
genSalt
(
10
,
function
(
err
,
salt
)
{
if
(
err
)
if
(
err
)
return
cb
(
err
);
return
next
(
err
);
bcrypt
.
hash
(
attrs
.
password
,
salt
,
null
,
function
(
err
,
hash
)
{
bcrypt
.
hash
(
attrs
.
password
,
salt
,
null
,
function
(
err
,
hash
)
{
if
(
err
)
if
(
err
)
return
cb
(
err
);
return
next
(
err
);
attrs
.
password
=
hash
;
attrs
.
password
=
hash
;
next
();
cb
();
});
});
});
}
],
function
(
err
)
{
if
(
err
)
return
next
(
err
);
next
();
});
});
},
},
...
@@ -220,18 +221,24 @@ module.exports = {
...
@@ -220,18 +221,24 @@ module.exports = {
//
//
beforeUpdate
:
function
(
attrs
,
next
)
{
beforeUpdate
:
function
(
attrs
,
next
)
{
async
.
series
([
function
(
cb
)
{
//
//
// Check that user email does not exist
// Check that user email does not exist
//
//
if
(
attrs
.
email
){
if
(
attrs
.
email
){
Supervisor
.
findByEmail
(
attrs
.
email
).
exec
(
function
(
err
,
users
)
{
Supervisor
.
findByEmail
(
attrs
.
email
).
exec
(
function
(
err
,
users
)
{
if
(
err
)
if
(
err
)
return
next
(
err
);
return
cb
(
err
);
if
(
users
.
length
>
0
)
if
(
users
.
length
>
0
)
return
next
(
new
Error
(
'User email already exists'
));
return
cb
(
new
Error
(
'User email already exists'
));
cb
();
});
});
}
else
{
return
cb
(
new
Error
(
'No email in user attributes'
));
}
}
},
function
(
cb
)
{
//
//
// Encrypt password before insertion
// Encrypt password before insertion
//
//
...
@@ -239,18 +246,20 @@ module.exports = {
...
@@ -239,18 +246,20 @@ module.exports = {
var
bcrypt
=
require
(
'bcrypt-nodejs'
);
var
bcrypt
=
require
(
'bcrypt-nodejs'
);
bcrypt
.
genSalt
(
10
,
function
(
err
,
salt
)
{
bcrypt
.
genSalt
(
10
,
function
(
err
,
salt
)
{
if
(
err
)
if
(
err
)
return
cb
(
err
);
return
next
(
err
);
bcrypt
.
hash
(
attrs
.
password
,
salt
,
null
,
function
(
err
,
hash
)
{
bcrypt
.
hash
(
attrs
.
password
,
salt
,
null
,
function
(
err
,
hash
)
{
if
(
err
)
if
(
err
)
return
cb
(
err
);
return
next
(
err
);
attrs
.
password
=
hash
;
attrs
.
password
=
hash
;
next
();
cb
();
});
});
});
});
}
else
{
}
else
{
next
();
cb
();
}
}
}],
function
(
err
)
{
if
(
err
)
return
next
(
err
);
next
();
});
},
},
//
//
...
...
sails/src/assets/app/img/logo_pictogram.png
View file @
ebc987b4
9.04 KB
|
W:
|
H:
4.5 KB
|
W:
|
H:
2-up
Swipe
Onion skin
sails/src/assets/app/modules/login/controllers/signin.js
View file @
ebc987b4
...
@@ -21,7 +21,7 @@ dashboardControllers.controller('SignInCtrl', function SignInCtrl($scope, $http,
...
@@ -21,7 +21,7 @@ dashboardControllers.controller('SignInCtrl', function SignInCtrl($scope, $http,
lang
:
'es'
lang
:
'es'
};
};
reCAPTCHA
.
setPublicKey
(
'6Ld
kZwMTAAAAANDR_7_y9_ifEve1gLPcgneM_50o
'
);
reCAPTCHA
.
setPublicKey
(
'6Ld
Ljh0TAAAAANblo_KUGNnmRZuIetOkdjdhj1b6
'
);
/* NOT NECESSARY
/* NOT NECESSARY
// Array of key terms to translate
// Array of key terms to translate
...
@@ -84,7 +84,7 @@ dashboardControllers.controller('SignInCtrl', function SignInCtrl($scope, $http,
...
@@ -84,7 +84,7 @@ dashboardControllers.controller('SignInCtrl', function SignInCtrl($scope, $http,
$scope
.
alert
=
"alert-danger"
;
$scope
.
alert
=
"alert-danger"
;
$scope
.
message
=
"user_exists"
;
$scope
.
message
=
"user_exists"
;
console
.
log
(
"Error from API: "
+
data
.
error
);
console
.
log
(
"Error from API: "
+
status
);
});
});
};
};
...
...
sails/src/assets/app/modules/login/views/signin.html
View file @
ebc987b4
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