aboutsummaryrefslogtreecommitdiffstats
path: root/install.js
blob: 6432fb1d0b32ea7e4bae32e64d9eeb7e4c23cf22 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
(function() {
  var bcrypt, db;
  db = require("./redis");
  bcrypt = require('bcrypt');

  db.get("user:admin", function(err, res) {
    if (!res) {
      return bcrypt.hash('admin', 12, function(err, hash) {
        db.sadd("users", "user:admin");
        return db.hmset("user:admin", {
          username: 'admin',
          password: hash
        }, function() {
          console.log("Created admin user with password 'admin'");
          return process.exit();
        });
      });
    }
  });

}).call(this);