|
|
@@ -32,7 +32,8 @@ app.all('/register', function(req, res) {
|
|
32
|
32
|
bcrypt.hash(tmp_password, null, null, function (err, hash) {
|
|
33
|
33
|
user_object["password"] = hash;
|
|
34
|
34
|
user_object["auth-key"] = bcrypt.hashSync(Date.now().toString() + tmp_username);
|
|
35
|
|
- redis.set(uquery, JSON.stringify(user_object));
|
|
|
35
|
+ redis.hset(uquery, "password", user_object.password);
|
|
|
36
|
+ redis.hset(uquery, "auth-key", user_object["auth-key"]);
|
|
36
|
37
|
res.send({"registered": 1,
|
|
37
|
38
|
"auth-key": user_object["auth-key"],
|
|
38
|
39
|
"error": 0});
|
|
|
@@ -48,14 +49,14 @@ app.all('/login', function(req, res) {
|
|
48
|
49
|
var auth_key = req.body.auth_key || req.query.auth_key;
|
|
49
|
50
|
var uquery = 'user:' + username;
|
|
50
|
51
|
|
|
51
|
|
- redis.get(uquery).then(function (result) {
|
|
|
52
|
+ redis.hgetall(uquery).then(function (result) {
|
|
52
|
53
|
if (result !== "" && result !== undefined && result !== null) {
|
|
53
|
|
- var user_object = JSON.parse(result);
|
|
|
54
|
+ var user_object = result;
|
|
54
|
55
|
if (auth_key !== "" && auth_key !== undefined && auth_key !== null) {
|
|
55
|
56
|
if (auth_key === user_object["auth-key"]) {
|
|
56
|
57
|
var timestamp_user = Date.now().toString() + username;
|
|
57
|
58
|
user_object["auth-key"] = bcrypt.hashSync(timestamp_user);
|
|
58
|
|
- redis.set(uquery, JSON.stringify(user_object));
|
|
|
59
|
+ redis.set(uquery, "auth-key", user_object["auth-key"]);
|
|
59
|
60
|
res.send({"logged_in": 1,
|
|
60
|
61
|
"auth-key": user_object["auth-key"],
|
|
61
|
62
|
"error": 0});
|