update v1.0.5
This commit is contained in:
@@ -1,24 +1,22 @@
|
||||
<?php namespace App\Http\Controllers\Auth;
|
||||
|
||||
// controllers
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Controllers\Common\SettingsController;
|
||||
|
||||
// requests
|
||||
use App\Http\Requests\helpdesk\LoginRequest;
|
||||
use App\Http\Requests\helpdesk\RegisterRequest;
|
||||
use App\User;
|
||||
|
||||
// classes
|
||||
/* include User Model */
|
||||
use Hash;
|
||||
/* Include RegisterRequest */
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
/* Register validation */
|
||||
use Illuminate\Contracts\Auth\Registrar;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
|
||||
/* Include login validator */
|
||||
use Mail;
|
||||
use Auth;
|
||||
// Model
|
||||
// use App\Model\helpdesk\Utility\Limit_Login;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* ---------------------------------------------------
|
||||
@@ -58,8 +56,6 @@ class AuthController extends Controller {
|
||||
$this->middleware('guest', ['except' => 'getLogout']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get the form for registration
|
||||
* @return type Response
|
||||
@@ -78,7 +74,6 @@ class AuthController extends Controller {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Post registration form
|
||||
* @param type User $user
|
||||
@@ -148,26 +143,19 @@ class AuthController extends Controller {
|
||||
* @return type Response
|
||||
*/
|
||||
public function postLogin(LoginRequest $request) {
|
||||
|
||||
// Set login attempts and login time
|
||||
$loginAttempts = 1;
|
||||
$credentials = $request->only('email', 'password');
|
||||
|
||||
$email = $request->email;
|
||||
// $ip_address = $_SERVER['REMOTE_ADDR'];
|
||||
|
||||
// $limit_login = Limit_Login::where('email' , '=' , $email)->where('ip_address', '=', $ip_address)->first();
|
||||
// if(isset($limit_login)) {
|
||||
|
||||
// }
|
||||
|
||||
|
||||
|
||||
$usernameinput = $request->input('email');
|
||||
$password = $request->input('password');
|
||||
$field = filter_var($usernameinput, FILTER_VALIDATE_EMAIL) ? 'email' : 'user_name';
|
||||
// If session has login attempts, retrieve attempts counter and attempts time
|
||||
if (\Session::has('loginAttempts')) {
|
||||
$loginAttempts = \Session::get('loginAttempts');
|
||||
$loginAttemptTime = \Session::get('loginAttemptTime');
|
||||
$credentials = $request->only('email', 'password');
|
||||
// $credentials = $request->only('email', 'password');
|
||||
$usernameinput = $request->input('email');
|
||||
$password = $request->input('password');
|
||||
$field = filter_var($usernameinput, FILTER_VALIDATE_EMAIL) ? 'email' : 'user_name';
|
||||
// If attempts > 3 and time < 10 minutes
|
||||
if ($loginAttempts > 4 && (time() - $loginAttemptTime <= 600)) {
|
||||
return redirect()->back()->with('error', 'Maximum login attempts reached. Try again in a while');
|
||||
@@ -177,14 +165,13 @@ class AuthController extends Controller {
|
||||
\Session::put('loginAttempts', 1);
|
||||
\Session::put('loginAttemptTime', time());
|
||||
}
|
||||
} else // If no login attempts stored, init login attempts and time
|
||||
{
|
||||
} else { // If no login attempts stored, init login attempts and time
|
||||
\Session::put('loginAttempts', $loginAttempts);
|
||||
\Session::put('loginAttemptTime', time());
|
||||
}
|
||||
// If auth ok, redirect to restricted area
|
||||
\Session::put('loginAttempts', $loginAttempts + 1);
|
||||
if ($this->auth->attempt($credentials, $request->has('remember'))) {
|
||||
if ($this->auth->attempt([$field => $usernameinput, 'password' => $password], $request->has('remember'))) {
|
||||
if(Auth::user()->role == 'user') {
|
||||
return \Redirect::route('/');
|
||||
} else {
|
||||
@@ -208,100 +195,4 @@ class AuthController extends Controller {
|
||||
return 'This Field do not match our records.';
|
||||
}
|
||||
|
||||
|
||||
// public function postLogin(LoginRequest $request) {
|
||||
// $email = $request->input('email');
|
||||
// $counter = 0;
|
||||
// $user = User::where('email','=',$email)->first();
|
||||
// if($user) {
|
||||
// if($user->active == 1) {
|
||||
// $credentials = $request->only('email', 'password');
|
||||
|
||||
// while($counter < 10) {
|
||||
// if($this->auth->attempt($credentials) === false) {
|
||||
// $counter++;
|
||||
// }
|
||||
// }
|
||||
// if ($this->auth->attempt($credentials, $request->has('remember'))) {
|
||||
// if(Auth::user()) {
|
||||
// if(Auth::user()->role == 'vendor') {
|
||||
// return \Redirect::route('vendors.index');
|
||||
// } elseif(Auth::user()->role == 'admin') {
|
||||
// return \Redirect::route('admin.dashboard');
|
||||
// } elseif(Auth::user()->role == 'sadmin') {
|
||||
// return \Redirect::route('sadmin.dashboard');
|
||||
// } else {
|
||||
// return redirect()->intended($this->redirectPath());
|
||||
// }
|
||||
// } else {
|
||||
// return redirect()->back()->with('message','Account Inactive, Please wait for Admin to approve.');
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// return redirect()->back()->with('message','Account Inactive, Please wait for Admin to approve.');
|
||||
// }
|
||||
// }
|
||||
// return redirect($this->loginPath())
|
||||
// ->withInput($request->only('email', 'remember'))
|
||||
// ->withErrors(['email' => $this->getFailedLoginMessage(), 'password' => $this->getFailedLoginMessage(), ]);
|
||||
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
// public function authenticate() {
|
||||
// // Set login attempts and login time
|
||||
// $loginAttempts = 1;
|
||||
// // If session has login attempts, retrieve attempts counter and attempts time
|
||||
// if (Session::has('loginAttempts')) {
|
||||
// $loginAttempts = Session::get('loginAttempts');
|
||||
// $loginAttemptTime = Session::get('loginAttemptTime');
|
||||
// // If attempts > 3 and time < 10 minutes
|
||||
// if ($loginAttempts > 3 && (time() - $loginAttemptTime <= 600)) {
|
||||
// return redirect()-back()->with('error', 'maximum login attempts reached. Try again in a while');
|
||||
// }
|
||||
// // If time > 10 minutes, reset attempts counter and time in session
|
||||
// if (time() - $loginAttemptTime > 600) {
|
||||
// Session::put('loginAttempts', 1);
|
||||
// Session::put('loginAttemptTime', time());
|
||||
// }
|
||||
// } else // If no login attempts stored, init login attempts and time
|
||||
// {
|
||||
// Session::put('loginAttempts', $loginAttempts);
|
||||
// Session::put('loginAttemptTime', time());
|
||||
// }
|
||||
// // If auth ok, redirect to restricted area
|
||||
// if (Auth::attempt(['email' => 'someone@example.com'])) {
|
||||
// return redirect()->intended('dashboard');
|
||||
// }
|
||||
// // Increment login attempts
|
||||
// Session::put('loginAttempts', $loginAttempts + 1);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// public function postLogin(LoginRequest $request) {
|
||||
// // $email = $request->input('email');
|
||||
// // $password = Hash::make($request->input('password'));
|
||||
// // $remember = $request->input('remember');
|
||||
// // dd([$email,$password,$remember]);
|
||||
// $credentials = $request->only('email', 'password');
|
||||
// if ($this->auth->attempt($credentials, $request->has('remember'))) {
|
||||
// if(Auth::user()->role == 'user') {
|
||||
// return \Redirect::route('home');
|
||||
// } else {
|
||||
// return redirect()->intended($this->redirectPath());
|
||||
// }
|
||||
// }
|
||||
// return redirect($this->loginPath())
|
||||
// ->withInput($request->only('email', 'remember'))
|
||||
// ->withErrors([
|
||||
// 'email' => $this->getFailedLoginMessage(),
|
||||
// 'password' => $this->getFailedLoginMessage(),
|
||||
// ]);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user