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

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.

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.

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

Related

What's the easiest way to generate forms using laravel and js?

I have form when user can add achievement.
So it looks like:
<form action="{{ action('SettingsController#addAchievementsSettings') }}" method="post" class="form-horizontal">
{{ csrf_field() }}
<div class="form-group">
<label class="col-lg-2 control-label">Date</label>
<div class="col-lg-6">
<input type="date" placeholder=" " id="date-achievement" name="date_achievement" class="form-control">
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">What</label>
<div class="col-lg-6">
<input type="text" placeholder=" " id="what-achievement" name="what_achievement" class="form-control">
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">Description</label>
<div class="col-lg-10">
<textarea rows="10" cols="30" class="form-control" id="description_achievement" name="description_achievement"></textarea>
</div>
</div>
<button type="button" class="btn btn-warning">Add one more...</button>
<button type="submit" class="btn btn-success">Save</button>
I want to generate another form if somebody click Add one more. How can I reach this and how to add everything to database? Sorry guys for not more code but I do not have any idea
from your question it seems a proper video / tutorial would help you more than just the answer.
for generation I personally use laravelcollective/html.
a good site with lots of videos explaining almost everything in regards to laravel and building sites with it I recomment the laracasts site.
to learn how to build and process forms with laravel I suggest Laravel 5.4 from scratch
specifically for working with forms: Form request data and form validation
After creating your form and submitting your form , you have to validate your data then you will call your model to insert your date in database, i suggest you eloquent to handle database request if you are using laravel

How to display error above input with bootstrap validator

I'm using Bootstrap validator for bootstrap 3 and trying to display error messages above the input.
Here is the provided HTML code example:
<form role="form" data-toggle="validator">
<div class="form-group">
<label for="inputEmail">Email</label>
<input type="email" id="inputEmail">
<div class="help-block with-errors"></div>
</div>
</form>
this works fine but I want to display the error like this:
<!-- display error -->
<div class="help-block with-errors"></div>
<!-- input -->
<div class="form-group">
<label for="inputEmail">Email</label>
<input type="email" id="inputEmail">
</div>
Am I missing something here, how to do it right?
or, is there another way to accomplish this task by using JavaScript? (if the first block of code is used, can I move the error above the input like the example of the 2nd code?)
Put the error inside the same parent div as the input. Try this:
<div class="form-group">
<div class="help-block with-errors"></div>
<label for="inputEmail">Email</label>
<input type="email" id="inputEmail">
</div>

html5 contact form with PHP [duplicate]

This question already has answers here:
How can I send an email using PHP?
(20 answers)
Closed 6 years ago.
This is the HTML contact form I created and I have been trying to get the PHP code that will make it work however I am not sure the best way to handle this. I have read through other questions and answers where they use separate files I am not an expert in PHP but I can assume the two files must be linked by name this is the HTML form I have:
<section class="our-contacts slideanim" id="contact">
<h3 class="text-center slideanim">Contact Us</h3>
<p class="text-center slideanim">Got a project in mind? Shoot as an email below!</p>
<div class="container">
<div class="row">
<div class="col-lg-12">
<form role="form">
<div class="row">
<div class="form-group col-lg-4 slideanim">
<input type="text" name="name" class="form-control user-name" placeholder="Your Name" required/>
</div>
<div class="form-group col-lg-4 slideanim">
<input type="email" name="email" class="form-control mail" placeholder="Your Email" required/>
</div>
<div class="form-group col-lg-4 slideanim">
<input type="tel" class="form-control pno" placeholder="Your Phone Number" required/>
</div>
<div class="clearfix"></div>
<div class="form-group col-lg-12 slideanim">
<textarea name="message" class="form-control" rows="6" placeholder="Your Message" required/> </textarea>
</div>
<div class="form-group col-lg-12 slideanim">
<button type="submit" href="#" class="btn-outline1">Submit</button>
</div>
</div>
</form>
</div>
</div>
</div>
The form tag needs to have an action and a method attribute, like this:
<form role="form" method="post" action="path/to/file.php">
The method will normally be post (you can look up the difference between post and get if you like). The action is the path to the php file that will process the data.
In the php file you can access the data through the $_POST global variable which will be an array containing each of the inputs eg $_POST['tel'] will be the telephone number field from your form.
Then you need to send the email. You can try one of the implementations in the php manual (http://php.net/manual/en/refs.remote.mail.php) or you could try using a 3rd party service like mail gun.

How to create hidden 'payment_method_nonce' input by braintree.js?

I configure braintree.js like this:
braintree.setup(
brainTreeClientToken= 'token_from_server'
'dropin', {
container: 'brainTreeDropin',
form: 'checkout'
});
</script>
As i understand from the documentation of developers.braintree, you need to send a request param named 'payment_method_nonce' to your server, but it is not present in request. I don't see any js fault in browser console by the way.
Here is my form:
<form id="checkout" method="post"
th:action="....">
<div id="brainTreeDropin"></div>
<div >
<div class="form-group">
<label for="cardNumber">Credit Card Number</label>
<input data-braintree-name="number" ..other details.. "/>
</div>
<div class="form-group">
<label for="cardHolder">Name on Card</label>
<input data-braintree-name="cardholder_name" ..other details.. />
</div>
</div>
<div >
<div class="form-group">
<label for="cvc">Security Code(CVC)</label>
<input data-braintree-name="cvv" ..other details.. />
</div>
<div class="form-group">
<label for="expDate">Expiration Date</label>
<input data-braintree-name="expiration_date" ..other details.. />
</div>
</div>
</form>
Any idea of what's my fault?
I work at Braintree on the SDK Team.
The Drop-In integration requires a button or type=["submit"] element to be present within the form. I tried out your integration and was able to get a payment_method_nonce value sent to my server by adding in a <button>Pay</button> element. Try that out to see if that fixes your integration.
Also, just out of curiosity, is it your intent to have 2 credit card input methods inside of the same form? The Drop-In form contains the necessary fields for Credit Cards and you shouldn't need the data-braintree-name annotated inputs.

Angularjs.copy does not save to db?

I have a credit card form with a btn that pulls the address from the database (Use home address), its working in the sense that it shows up inside of the textfield but when saving the form, this textfield turns up empty in the db. Anyone got any feedback?
<div class="row clearfix">
<div class="col-md-12 column">
<div class="form-group">
<button href="" ng-click="getAddress(user)" value="Show" class="btn btn-general btn-xs">Use Home Address</button>
<input type="text" data-vkeysinput="" class="form-control" value="{{copyAddress}}"/>
</div>
</div>
</div>
$scope.getAddress = function(user) {
$scope.copyAddress= angular.copy(user.user_address.address_1);
};
angular.copy have absolutely nothing to do with a database.
AngularJS can't even talk to a database - you need some kind of backend to support that.

Categories

Resources