summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2014-07-09 20:49:20 -0400
committerJules Laplace <jules@okfoc.us>2014-07-09 20:49:20 -0400
commitd21afb68e2bf2db166d6bdad53d401f140e08d48 (patch)
tree569c70ec0c8943757ce954feea65e89e11420d00
parent0c7e6c8e93a0e168b055f45aeca47ac85e828fb0 (diff)
logging in for realzies
-rw-r--r--public/js/auth.js6
-rw-r--r--public/protocols/index.html1
-rw-r--r--server/auth/crypt.js (renamed from public/js/vendor/crypt.js)2
-rw-r--r--server/auth/index.js16
4 files changed, 11 insertions, 14 deletions
diff --git a/public/js/auth.js b/public/js/auth.js
index 651e396..9f366a2 100644
--- a/public/js/auth.js
+++ b/public/js/auth.js
@@ -33,13 +33,9 @@ var Auth =
Main.saving = true
warn("attempting login")
-
- var password = $('#login-password').val()
- password = unixCryptTD(password, password.substr(0,2))
-
var data = {
username: $('#login-email').val(),
- password: password,
+ password: $('#login-password').val(),
}
$('#login-password').val(''),
$.post(URL.auth.login, data, Auth.loginCallback)
diff --git a/public/protocols/index.html b/public/protocols/index.html
index 48344f1..2c04d3f 100644
--- a/public/protocols/index.html
+++ b/public/protocols/index.html
@@ -226,7 +226,6 @@ Illustration by <a href="http://mollycrabapple.com/" target="_blank">Molly Craba
</body>
<script type="text/javascript" src="/js/vendor/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="/js/vendor/base64.js"></script>
-<script type="text/javascript" src="/js/vendor/crypt.js"></script>
<script type="text/javascript" src="/js/util.js"></script>
<script type="text/javascript" src="/js/party.js"></script>
<script type="text/javascript" src="/js/user.js"></script>
diff --git a/public/js/vendor/crypt.js b/server/auth/crypt.js
index ddc97ec..485932e 100644
--- a/public/js/vendor/crypt.js
+++ b/server/auth/crypt.js
@@ -57,7 +57,7 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
* @param {boolean=} returnBytes (optional) If true, return an array of bytes;
* otherwise, return a string.
*/
-window['unixCryptTD'] = (function() {
+module.exports = (function() {
/*
* Initial permutation,
*/
diff --git a/server/auth/index.js b/server/auth/index.js
index e5cb2ea..e8fb483 100644
--- a/server/auth/index.js
+++ b/server/auth/index.js
@@ -4,7 +4,8 @@ var passport = require('passport'),
LocalStrategy = require('passport-local').Strategy,
_ = require('lodash'),
config = require('../../config.json'),
- User = require('../models/User');
+ User = require('../models/User'),
+ crypt = require('./crypt');
var auth = module.exports = {
@@ -73,16 +74,17 @@ var auth = module.exports = {
if (username == "protocolsnyc" && password == "madhousenyc") {
return done(null, auth.guestUser)
}
- User.findByUsername(username, function(err, user){
- if (err) { return done(err); }
- if (! user) {
- return done(null, false, { error: { errors: { username: { message: 'No such username.' } }}})
+ User.find({ where: { email: username } }).success(function(user){
+ if (! user.password || user.password.length < 2) {
+ return done(null, false, { error: { errors: { username: { message: 'No such user.' } }}})
}
- if (! user.validPassword(password)) {
+ else if ( crypt(password, user.password) !== user.password) {
return done(null, false, { error: { errors: { password: { message: 'Incorrect password.' } }}})
}
return done(null, user);
- });
+ }).error(function(){
+ return done(null, false, { error: { errors: { username: { message: 'No such username.' } }}})
+ })
}
}