On registration, password is getting saved as intended encrypted but while login, it is throwing a message that password is not matching, because encrypted password is not decrypting while login. Can any one help me out with this ? I want to login successfully with encrypted password.
Here is my controller
<?php
namespace App\Http\Controllers;
use App\Http\Requests;
use Illuminate\Http\Request;
use DB;
use Session;
use Redirect;
use App\User;
use App\Http\Requests\UserRequest as UserRequest;
// use App\Http\Requests\CreateArticleRequest as CreateArticleRequest;
use App\Http\Controllers\Controller;
use Illuminate\View\Middleware\ErrorBinder;
use Illuminate\Support\Facades\Input;
use Hash;
use Crypt;
use Bcrypt;
class ctrl extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
public function registration_function(Request $request)
{
$nam_value = $request->nam;
$email_value = $request->r_email;
$password_value = $request->r_password;
$city_value = $request->city;
$login_email = $request->l_email;
$login_password = $request->l_password;
$bcrypt = new Bcrypt(15);
$password_value = $bcrypt->hash($password_value);
$login_password = $bcrypt->verify($password_value, $login_password);
// $password_value = Crypt::encrypt($password_value);
// $login_password = Crypt::encrypt($password_value);
if($email_value)
{
$valid_user = DB::table('registered')
->where('email',$email_value)
->get();
if($valid_user)
{
return redirect('makelogin_page')->with('status_validate','You are already registered with us, Plaese login, Did you forgot your password ?');
}
else
{
$reg=DB::table('registered')->insert(['name' => $nam_value, 'email' => $email_value, 'password'=>$password_value,'city'=>$city_value]);
return redirect('makelogin_page')->with('status','Registered Successfully');
}
}
else
{
$log_display = DB::table('registered')
->where('email',$login_email)
->where('password',$login_password)
->get();
if($log_display)
{
return redirect('dodofront');
}
else
{
return redirect('makelogin_page')->with('status','Please enter the valid credentials, Did you forgot your password ?');
}
}
}
}
Here is my blade.php page
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Dashboard | Design Dodo</title>
<!-- Bootstrap -->
<link href="main.css" rel="stylesheet"/>
<script src="bootstrap/jquery.min.js"></script>
<script src="bootstrap/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
</head>
<body>
<br/>
<div class="container">
<h3>New user ?</h3>
<!-- Trigger the modal with a button -->
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#registration">Register</button>
<!-- Modal -->
<div class="modal fade" id="registration" role="dialog">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Registration</h4>
</div>
<div class="modal-body">
<p>Please Register Yourself Here</p>
<form role="form" action="registration_page" method="get">
<div class="form-group">
<input type="text" class="form-control" name="nam" placeholder="Your Name Please" style="width:265px;" required/>
</div>
<div class="form-group">
<input type="email" class="form-control" name="r_email" placeholder="Your Email Please" style="width:265px;" required/>
</div>
<div class="form-group">
<input type="password" class="form-control" name="r_password" placeholder="Please enter a password" style="width:265px;" required/>
</div>
<div class="form-group">
<input type="text" class="form-control" name="city" placeholder="Please enter your city" style="width:265px;" required/>
</div>
<div class="form-group">
<input type="submit" class="btn btn-info" value="Register">
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<h3>Existing user ?</h3>
<!-- Trigger the modal with a button -->
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#login">Login</button>
<!-- Modal -->
<div class="modal fade" id="login" role="dialog">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Login</h4>
</div>
<div class="modal-body">
<p>Please Login Here</p>
<form role="form" action="login_page" method="get">
<div class="form-group">
<input type="email" class="form-control" name="l_email" placeholder="Your Email Please" style="width:265px;" required/>
</div>
<div class="form-group">
<input type="password" class="form-control" name="l_password" placeholder="Please enter a password" style="width:265px;" required/>
</div>
<div>
<input type="submit" class="btn btn-info" value="login">
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
</body>
And here is route
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', function () {
return view('welcome');
});
Route::auth();
Route::get('/registration_page','ctrl@registration_function');
Route::get('/login_page','ctrl@registration_function');
THis code is throwing an error which is
FatalErrorException in ctrl.php line 40:
Class 'Bcrypt' not found
Please help me to solve this issue