Skip to content Skip to sidebar Skip to footer

Referenceerror: User Is Not Defined

I've got an error while i try to auth via vkontakte (vk.com) (passport-vkontakte) Error: ReferenceError: User is not defined Here is my auth.js var express = require('express'); va

Solution 1:

Define User Model

Mongoose or Mongoskin Example

var mongoose = require('mongoose');

mongoose.connect('mongodb://localhost/my_database');

varSchema = mongoose.Schema
  , ObjectId = Schema.ObjectId;

varBlogPost = newSchema({
    author    : ObjectId
  , title     : String
  , body      : String
  , date      : Date
});

varPost = mongoose.model('ModelName', BlogPost);

Post.findOrCreate({ id: QUERY }, function (err, docs) {

});

You need to create a model so your strategy can interact with your application properly. In your case, this model will be for users so it is appropriately named User as an entity.

Boilerplate Code to Get You Started

This code was added from the strategy developers to get you started.

User.findOrCreate({ vkontakteId: profile.id }, function (err, user) {
    returndone(err, user);
});

It's the same concept, hope this clears things up.

Post a Comment for "Referenceerror: User Is Not Defined"