Laravel 5 Auth::attempt always return false, even if i typed correct data ? (LARAVEL)





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







-1















I created custom login system on LARAVEL app, everything has worked perfectly until yesterday. When i typed in login form email and password for user that is same as from database, system redirect me back. I don't know what is problem, i cleared cache and everything but still it doesn't work. If someone know answer i would really appreciate.




Login page image:




https://imgur.com/a/xuEWQZg




Data of user stored in database whit seed :




https://imgur.com/0mJOviV



`




dd function with sent data from login form :




` https://imgur.com/a/D2k8Ztn



Main controller



  function checklogin(Request $request)
{
$this->validate($request, [
'email' => 'required|email',
'password' => 'required|alphaNum|min:3'
]);

$user_data = array(
'email' => $request->get('email'),
'password' => $request->get('password')
);
if(Auth::attempt($user_data))
{

return redirect('');
}
else
{
return back()->with('error', 'you typed wrong data');
}

}


login page



@extends('layout')

@section('content')
<div class="container2">
<div class="container">
<div class="card card-container">

<h1 style="text-align: center;">Admin login</h1>


@if(isset(Auth::user()->email))
<script>window.location="/main/successlogin";</script>
@endif

@if ($message = Session::get('error'))
<div class="alert alert-danger alert-block">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>{{ $message }}</strong>
</div>
@endif

@if (count($errors) > 0)
<div class="alert alert-danger">
<ul>
@foreach($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif

<form method="post" action="{{ url('/main/checklogin') }}">
{{ csrf_field() }}
<div class="form-group">
<label>Unesi email</label>
<input type="email" name="email" class="form-control" />
</div>
<div class="form-group">
<label>Unesi šifru</label>
<input type="password" name="password" class="form-control" />
</div>
<div class="form-group">
<input type="submit" name="login" class="btn btn-primary" value="Login" />
</div>
</form>
</div><!-- /card-container -->
</div><!-- /container -->
</div><!-- /container -->
@endsection


Routes



Route::get('/', 'MainController@successlogin')->name('main');
Route::get('/admin', 'MainController@index');
Route::post('/main/checklogin', 'MainController@checklogin');
Route::get('main/logout', 'MainController@logout');


User model



<?php

namespace App;

use IlluminateNotificationsNotifiable;
use IlluminateFoundationAuthUser as Authenticatable;

class User extends Authenticatable
{
use Notifiable;

/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password', 'lastname', 'level',
];

/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
}









share|improve this question

























  • can you show your database

    – Shaielndra Gupta
    Nov 16 '18 at 19:15











  • Those passwords aren't the same are they? Most hashes are, and should be, case sensitive.

    – Devon
    Nov 16 '18 at 19:15











  • Password in database and in login form that i typed are same

    – Nenad
    Nov 16 '18 at 19:19











  • imgur.com/a/cTztlJ6

    – Nenad
    Nov 16 '18 at 19:19











  • Because the password fields are case sensitive you have D at the start of password field so you have to send D instead of small d

    – Shaielndra Gupta
    Nov 16 '18 at 19:22


















-1















I created custom login system on LARAVEL app, everything has worked perfectly until yesterday. When i typed in login form email and password for user that is same as from database, system redirect me back. I don't know what is problem, i cleared cache and everything but still it doesn't work. If someone know answer i would really appreciate.




Login page image:




https://imgur.com/a/xuEWQZg




Data of user stored in database whit seed :




https://imgur.com/0mJOviV



`




dd function with sent data from login form :




` https://imgur.com/a/D2k8Ztn



Main controller



  function checklogin(Request $request)
{
$this->validate($request, [
'email' => 'required|email',
'password' => 'required|alphaNum|min:3'
]);

$user_data = array(
'email' => $request->get('email'),
'password' => $request->get('password')
);
if(Auth::attempt($user_data))
{

return redirect('');
}
else
{
return back()->with('error', 'you typed wrong data');
}

}


login page



@extends('layout')

@section('content')
<div class="container2">
<div class="container">
<div class="card card-container">

<h1 style="text-align: center;">Admin login</h1>


@if(isset(Auth::user()->email))
<script>window.location="/main/successlogin";</script>
@endif

@if ($message = Session::get('error'))
<div class="alert alert-danger alert-block">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>{{ $message }}</strong>
</div>
@endif

@if (count($errors) > 0)
<div class="alert alert-danger">
<ul>
@foreach($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif

<form method="post" action="{{ url('/main/checklogin') }}">
{{ csrf_field() }}
<div class="form-group">
<label>Unesi email</label>
<input type="email" name="email" class="form-control" />
</div>
<div class="form-group">
<label>Unesi šifru</label>
<input type="password" name="password" class="form-control" />
</div>
<div class="form-group">
<input type="submit" name="login" class="btn btn-primary" value="Login" />
</div>
</form>
</div><!-- /card-container -->
</div><!-- /container -->
</div><!-- /container -->
@endsection


Routes



Route::get('/', 'MainController@successlogin')->name('main');
Route::get('/admin', 'MainController@index');
Route::post('/main/checklogin', 'MainController@checklogin');
Route::get('main/logout', 'MainController@logout');


User model



<?php

namespace App;

use IlluminateNotificationsNotifiable;
use IlluminateFoundationAuthUser as Authenticatable;

class User extends Authenticatable
{
use Notifiable;

/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password', 'lastname', 'level',
];

/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
}









share|improve this question

























  • can you show your database

    – Shaielndra Gupta
    Nov 16 '18 at 19:15











  • Those passwords aren't the same are they? Most hashes are, and should be, case sensitive.

    – Devon
    Nov 16 '18 at 19:15











  • Password in database and in login form that i typed are same

    – Nenad
    Nov 16 '18 at 19:19











  • imgur.com/a/cTztlJ6

    – Nenad
    Nov 16 '18 at 19:19











  • Because the password fields are case sensitive you have D at the start of password field so you have to send D instead of small d

    – Shaielndra Gupta
    Nov 16 '18 at 19:22














-1












-1








-1








I created custom login system on LARAVEL app, everything has worked perfectly until yesterday. When i typed in login form email and password for user that is same as from database, system redirect me back. I don't know what is problem, i cleared cache and everything but still it doesn't work. If someone know answer i would really appreciate.




Login page image:




https://imgur.com/a/xuEWQZg




Data of user stored in database whit seed :




https://imgur.com/0mJOviV



`




dd function with sent data from login form :




` https://imgur.com/a/D2k8Ztn



Main controller



  function checklogin(Request $request)
{
$this->validate($request, [
'email' => 'required|email',
'password' => 'required|alphaNum|min:3'
]);

$user_data = array(
'email' => $request->get('email'),
'password' => $request->get('password')
);
if(Auth::attempt($user_data))
{

return redirect('');
}
else
{
return back()->with('error', 'you typed wrong data');
}

}


login page



@extends('layout')

@section('content')
<div class="container2">
<div class="container">
<div class="card card-container">

<h1 style="text-align: center;">Admin login</h1>


@if(isset(Auth::user()->email))
<script>window.location="/main/successlogin";</script>
@endif

@if ($message = Session::get('error'))
<div class="alert alert-danger alert-block">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>{{ $message }}</strong>
</div>
@endif

@if (count($errors) > 0)
<div class="alert alert-danger">
<ul>
@foreach($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif

<form method="post" action="{{ url('/main/checklogin') }}">
{{ csrf_field() }}
<div class="form-group">
<label>Unesi email</label>
<input type="email" name="email" class="form-control" />
</div>
<div class="form-group">
<label>Unesi šifru</label>
<input type="password" name="password" class="form-control" />
</div>
<div class="form-group">
<input type="submit" name="login" class="btn btn-primary" value="Login" />
</div>
</form>
</div><!-- /card-container -->
</div><!-- /container -->
</div><!-- /container -->
@endsection


Routes



Route::get('/', 'MainController@successlogin')->name('main');
Route::get('/admin', 'MainController@index');
Route::post('/main/checklogin', 'MainController@checklogin');
Route::get('main/logout', 'MainController@logout');


User model



<?php

namespace App;

use IlluminateNotificationsNotifiable;
use IlluminateFoundationAuthUser as Authenticatable;

class User extends Authenticatable
{
use Notifiable;

/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password', 'lastname', 'level',
];

/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
}









share|improve this question
















I created custom login system on LARAVEL app, everything has worked perfectly until yesterday. When i typed in login form email and password for user that is same as from database, system redirect me back. I don't know what is problem, i cleared cache and everything but still it doesn't work. If someone know answer i would really appreciate.




Login page image:




https://imgur.com/a/xuEWQZg




Data of user stored in database whit seed :




https://imgur.com/0mJOviV



`




dd function with sent data from login form :




` https://imgur.com/a/D2k8Ztn



Main controller



  function checklogin(Request $request)
{
$this->validate($request, [
'email' => 'required|email',
'password' => 'required|alphaNum|min:3'
]);

$user_data = array(
'email' => $request->get('email'),
'password' => $request->get('password')
);
if(Auth::attempt($user_data))
{

return redirect('');
}
else
{
return back()->with('error', 'you typed wrong data');
}

}


login page



@extends('layout')

@section('content')
<div class="container2">
<div class="container">
<div class="card card-container">

<h1 style="text-align: center;">Admin login</h1>


@if(isset(Auth::user()->email))
<script>window.location="/main/successlogin";</script>
@endif

@if ($message = Session::get('error'))
<div class="alert alert-danger alert-block">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>{{ $message }}</strong>
</div>
@endif

@if (count($errors) > 0)
<div class="alert alert-danger">
<ul>
@foreach($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif

<form method="post" action="{{ url('/main/checklogin') }}">
{{ csrf_field() }}
<div class="form-group">
<label>Unesi email</label>
<input type="email" name="email" class="form-control" />
</div>
<div class="form-group">
<label>Unesi šifru</label>
<input type="password" name="password" class="form-control" />
</div>
<div class="form-group">
<input type="submit" name="login" class="btn btn-primary" value="Login" />
</div>
</form>
</div><!-- /card-container -->
</div><!-- /container -->
</div><!-- /container -->
@endsection


Routes



Route::get('/', 'MainController@successlogin')->name('main');
Route::get('/admin', 'MainController@index');
Route::post('/main/checklogin', 'MainController@checklogin');
Route::get('main/logout', 'MainController@logout');


User model



<?php

namespace App;

use IlluminateNotificationsNotifiable;
use IlluminateFoundationAuthUser as Authenticatable;

class User extends Authenticatable
{
use Notifiable;

/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password', 'lastname', 'level',
];

/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
}






php laravel login






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 16 '18 at 18:54







Nenad

















asked Nov 16 '18 at 18:11









NenadNenad

648




648













  • can you show your database

    – Shaielndra Gupta
    Nov 16 '18 at 19:15











  • Those passwords aren't the same are they? Most hashes are, and should be, case sensitive.

    – Devon
    Nov 16 '18 at 19:15











  • Password in database and in login form that i typed are same

    – Nenad
    Nov 16 '18 at 19:19











  • imgur.com/a/cTztlJ6

    – Nenad
    Nov 16 '18 at 19:19











  • Because the password fields are case sensitive you have D at the start of password field so you have to send D instead of small d

    – Shaielndra Gupta
    Nov 16 '18 at 19:22



















  • can you show your database

    – Shaielndra Gupta
    Nov 16 '18 at 19:15











  • Those passwords aren't the same are they? Most hashes are, and should be, case sensitive.

    – Devon
    Nov 16 '18 at 19:15











  • Password in database and in login form that i typed are same

    – Nenad
    Nov 16 '18 at 19:19











  • imgur.com/a/cTztlJ6

    – Nenad
    Nov 16 '18 at 19:19











  • Because the password fields are case sensitive you have D at the start of password field so you have to send D instead of small d

    – Shaielndra Gupta
    Nov 16 '18 at 19:22

















can you show your database

– Shaielndra Gupta
Nov 16 '18 at 19:15





can you show your database

– Shaielndra Gupta
Nov 16 '18 at 19:15













Those passwords aren't the same are they? Most hashes are, and should be, case sensitive.

– Devon
Nov 16 '18 at 19:15





Those passwords aren't the same are they? Most hashes are, and should be, case sensitive.

– Devon
Nov 16 '18 at 19:15













Password in database and in login form that i typed are same

– Nenad
Nov 16 '18 at 19:19





Password in database and in login form that i typed are same

– Nenad
Nov 16 '18 at 19:19













imgur.com/a/cTztlJ6

– Nenad
Nov 16 '18 at 19:19





imgur.com/a/cTztlJ6

– Nenad
Nov 16 '18 at 19:19













Because the password fields are case sensitive you have D at the start of password field so you have to send D instead of small d

– Shaielndra Gupta
Nov 16 '18 at 19:22





Because the password fields are case sensitive you have D at the start of password field so you have to send D instead of small d

– Shaielndra Gupta
Nov 16 '18 at 19:22












1 Answer
1






active

oldest

votes


















0














Try this:



function checklogin(Request $request)
{
$this->validate($request, [
'email' => 'required|email',
'password' => 'required|alphaNum|min:3'
]);

$user_data = array(
'email' => $request->get('email'),
'password' => bcrypt($request->get('password'))
);
if(Auth::attempt($user_data))
{

return redirect('');
}
else
{
return back()->with('error', 'you typed wrong data');
}

}





share|improve this answer
























  • The user is attempting to authenticate. No need to bcrypt here.

    – adam
    Nov 16 '18 at 19:57












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53343281%2flaravel-5-authattempt-always-return-false-even-if-i-typed-correct-data-lar%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Try this:



function checklogin(Request $request)
{
$this->validate($request, [
'email' => 'required|email',
'password' => 'required|alphaNum|min:3'
]);

$user_data = array(
'email' => $request->get('email'),
'password' => bcrypt($request->get('password'))
);
if(Auth::attempt($user_data))
{

return redirect('');
}
else
{
return back()->with('error', 'you typed wrong data');
}

}





share|improve this answer
























  • The user is attempting to authenticate. No need to bcrypt here.

    – adam
    Nov 16 '18 at 19:57
















0














Try this:



function checklogin(Request $request)
{
$this->validate($request, [
'email' => 'required|email',
'password' => 'required|alphaNum|min:3'
]);

$user_data = array(
'email' => $request->get('email'),
'password' => bcrypt($request->get('password'))
);
if(Auth::attempt($user_data))
{

return redirect('');
}
else
{
return back()->with('error', 'you typed wrong data');
}

}





share|improve this answer
























  • The user is attempting to authenticate. No need to bcrypt here.

    – adam
    Nov 16 '18 at 19:57














0












0








0







Try this:



function checklogin(Request $request)
{
$this->validate($request, [
'email' => 'required|email',
'password' => 'required|alphaNum|min:3'
]);

$user_data = array(
'email' => $request->get('email'),
'password' => bcrypt($request->get('password'))
);
if(Auth::attempt($user_data))
{

return redirect('');
}
else
{
return back()->with('error', 'you typed wrong data');
}

}





share|improve this answer













Try this:



function checklogin(Request $request)
{
$this->validate($request, [
'email' => 'required|email',
'password' => 'required|alphaNum|min:3'
]);

$user_data = array(
'email' => $request->get('email'),
'password' => bcrypt($request->get('password'))
);
if(Auth::attempt($user_data))
{

return redirect('');
}
else
{
return back()->with('error', 'you typed wrong data');
}

}






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 16 '18 at 19:55









Fabián Montero RodríguezFabián Montero Rodríguez

1376




1376













  • The user is attempting to authenticate. No need to bcrypt here.

    – adam
    Nov 16 '18 at 19:57



















  • The user is attempting to authenticate. No need to bcrypt here.

    – adam
    Nov 16 '18 at 19:57

















The user is attempting to authenticate. No need to bcrypt here.

– adam
Nov 16 '18 at 19:57





The user is attempting to authenticate. No need to bcrypt here.

– adam
Nov 16 '18 at 19:57




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53343281%2flaravel-5-authattempt-always-return-false-even-if-i-typed-correct-data-lar%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Florida Star v. B. J. F.

Error while running script in elastic search , gateway timeout

Adding quotations to stringified JSON object values