mkatanski
mkatanski

Reputation: 508

Sails.js 0.11 and passport: 'Missing Credentials' error

I've followed tutorial from this site: http://iliketomatoes.com/implement-passport-js-authentication-with-sails-js-0-10-2/

Signup form works correctly, everything is saved to my database (MongoDB) but when I want to log in, I've got missing credentials error:

{
  "message": "Missing credentials",
  "user": false
}

This is strange, I've cloned https://github.com/iliketomatoes/passport_with_sails , sails lift it and everything works fine. I've copied all api source files and configuration to my project. Only views are different but I'm sure that I'm using inputs with names: email and password. And still I have this error.

I was using MongoDB as a database, I've switched to local-disk (as in this repo) and still the same problem. I've changed versions of npm modules in package.json file to the one from the repo and still the same error. It is strange.

Also I have to mention that POST request contains email and password fields. I've double checked it.

Someone knows what can cause this problem?

EDIT: My login.ejs view looks like this:

<div class="row">
  <div id="content" class="col-sm-12 full">
    <div class="row">
      <div class="login-box">

        <div class="header">
          Login to JSCS Dashboard
        </div>


        <form class="form-horizontal login" action="/login" method="POST">

          <fieldset class="col-sm-12">
            <div class="form-group">
              <div class="controls row">
                <div class="input-group col-sm-12">
                  <input type="email" class="form-control" name="email" placeholder="E-mail"/>
                  <span class="input-group-addon"><i class="fa fa-user"></i></span>
                </div>
              </div>
            </div>

            <div class="form-group">
              <div class="controls row">
                <div class="input-group col-sm-12">
                  <input type="password" class="form-control" name="password" placeholder="Password"/>
                  <span class="input-group-addon"><i class="fa fa-key"></i></span>
                </div>
              </div>
            </div>

            <div class="row">


              <input type="submit" value="submit" class="btn btn-lg btn-primary col-xs-12">

            </div>

          </fieldset>

        </form>

        <a class="pull-left" href="auth-layout.ejs#">Forgot Password?</a>

        <div class="clearfix"></div>

      </div>
    </div><!--/row-->

  </div>



</div><!--/row-->

It is saved in Auth subfolder but displayed correctly. Signup form looks very similar to it and it works.

Upvotes: 1

Views: 613

Answers (2)

mkatanski
mkatanski

Reputation: 508

Ok, so the problem was that another service was interfering with AuthController. Anyway thanks for help

Upvotes: 1

Matan Gubkin
Matan Gubkin

Reputation: 3099

replace this:

<form class="form-horizontal login" action="/login" method="POST">.

with this:

<form class="form-horizontal login" action="/auth/local" method="POST">

also you might want to consider to use this tutorial instead: https://www.bearfruit.org/2014/07/21/tutorial-easy-authentication-for-sails-js-apps/

Its alot easier to implement It with that tutorial as it does most of the stuff you did automaticly.

Upvotes: 2

Related Questions