Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot get full example to work #35

Closed
valnub opened this issue Jun 28, 2015 · 4 comments
Closed

Cannot get full example to work #35

valnub opened this issue Jun 28, 2015 · 4 comments

Comments

@valnub
Copy link

valnub commented Jun 28, 2015

I tried the "full example" code:

var config = require('./config.js');
var Lockit = require('lockit');

var app = express();

app.use(cookieParser());
app.use(cookieSession({
  secret: 'secret'
}));

var lockit = new Lockit(config);

app.use(lockit.router);

// you now have all the routes like /login, /signup, etc.
// and you can listen on events. For example 'signup'
lockit.on('signup', function(user, res) {
  console.log('a new user signed up');
  res.send('Welcome!');   // set signup.handleResponse to 'false' for this to work
});

When I started the server it complained that express was undefined, so I installed express via npm and added:

var express = require('express');

and changed:

app.use(cookieParser());
app.use(cookieSession({
  secret: 'secret'
}));

to this:

app.use(express.cookieParser());
app.use(express.cookieSession({
  secret: 'secret'
}));

But now I get this. What's wrong?

lockit no email config found. Check your database for tokens.
/Users/valmar/dev/node/todolist/node_modules/lockit/node_modules/lockit-signup/index.js:40
  router.get(route, this.getSignup.bind(this));
        ^
TypeError: Cannot read property 'get' of undefined
    at new module.exports (/Users/valmar/dev/node/todolist/node_modules/lockit/node_modules/lockit-signup/index.js:40:9)
    at new module.exports (/Users/valmar/dev/node/todolist/node_modules/lockit/index.js:41:16)
    at Object.<anonymous> (/Users/valmar/dev/node/todolist/server.js:12:14)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3
@zemirco
Copy link
Owner

zemirco commented Jun 28, 2015

cookieParser and cookieSession are independent modules. Download the whole repo, cd into ./examples/default, run npm install and node app.js.

@valnub
Copy link
Author

valnub commented Jun 28, 2015

Ah, yes. Using the example did the trick. Also tried to add cookie-parser and cookie-session as dependencies in package.json but that didn't work :(
Anyway, thanks. I'll start with your example code then.

@valnub valnub closed this as completed Jun 28, 2015
@zemirco
Copy link
Owner

zemirco commented Jun 28, 2015

They already are dependencies in package.json.

@valnub
Copy link
Author

valnub commented Jun 28, 2015

Yeah, I know. I was talking about my project that I started from scratch. Not your example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants