title: Admin Password(Log in with a one password to webiste)
body: <p>I have procjet which will allow only admin to post and log in without username or registiration. So that I just used Password. But where I stack is, the issue that me and some of my friends which are involved to therese codings couldnt solve.
  This is a page that I referenced the code and the issue is same:<a href="https://stackoverflow.com/questions/60228711/nodejs-passportjs-giving-the-certain-password?noredirect=1#comment106532763_60228711">NodeJS-PassportJS Giving The Certain Password</a></p>
  
  <p>I have been using passport.js, nodejs and express.js with pug template.</p>
  
  <p>This is my user.js model:</p>
  
  <pre><code> const mongoose = require('mongoose');
  const UserSchema = mongoose.Schema({
      password:{
          type: String,
          required: true
        }
  });
  const User = module.exports = mongoose.model('User', UserSchema);
  </code></pre>
  
  <p>This is my passport.js</p>
  
  <pre><code>const LocalStrategy = require('passport-local').Strategy;
  const User = require('../models/user');
  const config = require('../config/database');
  const bcrypt = require('bcryptjs');
  
  module.exports = function(passport){
    // Local Strategy
    passport.use(new LocalStrategy(function(password){
  
      let query = {password:password};
      User.findOne(query, function(err, user){
        if(err) throw err;
        if(!user){
          return done(null, false, {message: 'No user found'});
        }
  
        // Match Password
        bcrypt.compare(password, user.password, function(err, isMatch){
          if(err) throw err;
          if(isMatch){
            return done(null, user);
          } else {
            return done(null, false, {message: 'Wrong password'});
          }
        });
      });
    }));
  
    passport.serializeUser(function(user, done) {
      done(null, user.id);
    });
  
    passport.deserializeUser(function(id, done) {
      User.findById(id, function(err, user) {
        done(err, user);
      });
  
    });
  }
  </code></pre>
  
  <p>This is my users.js</p>
  
  <pre><code>const express = require("express");
  const router = express.Router();
  const bcrypt = require('bcryptjs');
  const passport = require('passport');
  
  let User = require('../models/user');
  
  // Register Form
  router.get('/login', function(req, res){
      const password = req.body.password;
      req.checkBody('password', 'Password is required').notEmpty();
  
      let errors = req.validationErrors();
  
      res.render('login');
    });
  
    router.post('/login', function(req, res, next){
      passport.authenticate('local', {
        successRedirect:'/',
        failureRedirect:'/users/login',
        failureFlash: true
      })(req, res, next);
    });
  
    // logout
    router.get('/logout', function(req, res){
      req.logout();
      req.flash('success', 'You are logged out');
      res.redirect('/login');
    });
  
    module.exports = router; 
  </code></pre>
  
  <p>Also in db I have cerated a collection called user", because when I tried to do it with my code I find out the user. Maybe the problem can be in user.js(Models) or passport.js
  this is my comamnd line mongodb:</p>
  
  <pre><code>db.createCollection('users');
  ...
  db.users.insert{(password:'123'});
  ...
  </code></pre>
  
  <p>I need yout help, please it is my school homework and I have promised for that, I want to apply my promise. Please help to me. How can solve this.</p>