Merge remote-tracking branch 'refs/remotes/origin/developement' into manish-bug-fixes-and-updates
This commit is contained in:
@@ -296,15 +296,16 @@ class AuthController extends Controller
|
||||
}
|
||||
$field = filter_var($usernameinput, FILTER_VALIDATE_EMAIL) ? 'email' : 'user_name';
|
||||
$result = $this->confirmIPAddress($value, $usernameinput);
|
||||
|
||||
// If attempts > 3 and time < 30 minutes
|
||||
$security = Security::whereId('1')->first();
|
||||
//dd($security->lockout_message);
|
||||
if ($result == 1) {
|
||||
return redirect()->back()->withErrors('email', 'Incorrect details')->with(['error' => $security->lockout_message, 'referer' => $referer]);
|
||||
}
|
||||
//dd($request->input('email'));
|
||||
|
||||
$check_active = User::where('email', '=', $request->input('email'))->orwhere('user_name', '=', $request->input('email'))->first();
|
||||
if (!$check_active) {
|
||||
if (!$check_active) { //check if user exists or not
|
||||
//if user deos not exist then return back with error that user is not registered
|
||||
return redirect()->back()
|
||||
->withInput($request->only('email', 'remember'))
|
||||
->withErrors([
|
||||
@@ -313,19 +314,44 @@ class AuthController extends Controller
|
||||
])->with(['error' => Lang::get('lang.not-registered'),
|
||||
'referer' => $referer, ]);
|
||||
}
|
||||
|
||||
//if user exists
|
||||
$settings = CommonSettings::select('status')->where('option_name', '=', 'send_otp')->first();
|
||||
if ($settings->status == '0' || $settings->status == 0) {
|
||||
if ($check_active->active == 0) {
|
||||
return redirect()->back()
|
||||
->withInput($request->only('email', 'remember'))
|
||||
->withErrors([
|
||||
'email' => $this->getFailedLoginMessage(),
|
||||
'password' => $this->getFailedLoginMessage(),
|
||||
])->with(['error' => Lang::get('lang.this_account_is_currently_inactive'),
|
||||
'referer' => $referer, ]);
|
||||
|
||||
if ($settings->status == '1' || $settings->status == 1) { // check for otp verification setting
|
||||
// setting is enabled
|
||||
$sms = Plugin::select('status')->where('name', '=', 'SMS')->first();
|
||||
if ($sms) { //check sms plugin installed or not
|
||||
// plugin is installed
|
||||
if ($sms->status == 1 || $sms->status === '1') { //check plugin is active or not
|
||||
// plugin is active
|
||||
if (!$check_active->active) { //check account is active or not
|
||||
// account is not active show verify otp window
|
||||
if ($check_active->mobile) { //check user has mobile or not
|
||||
// user has mobile number return verify OTP screen
|
||||
return \Redirect::route('otp-verification')
|
||||
->withInput($request->input())
|
||||
->with(['values' => $request->input(),
|
||||
'referer' => $referer,
|
||||
'name' => $check_active->first_name,
|
||||
'number' => $check_active->mobile,
|
||||
'code' => $check_active->country_code, ]);
|
||||
} else {
|
||||
goto a; //attenmpt login (be careful while using goto statements)
|
||||
}
|
||||
} else {
|
||||
if ($check_active->active == 0 && !$check_active->mobile) {
|
||||
goto a; //attenmpt login (be careful while using goto statements)
|
||||
}
|
||||
} else {
|
||||
goto a; //attenmpt login (be careful while using goto statements)
|
||||
}
|
||||
} else {
|
||||
goto a; //attenmpt login (be careful while using goto statements)
|
||||
}
|
||||
} else {
|
||||
// setting is disabled
|
||||
a: if (!$check_active->active) { //check account is active or not
|
||||
// if accoutn is not active return back with error message that account is inactive
|
||||
return redirect()->back()
|
||||
->withInput($request->only('email', 'remember'))
|
||||
->withErrors([
|
||||
@@ -333,8 +359,8 @@ class AuthController extends Controller
|
||||
'password' => $this->getFailedLoginMessage(),
|
||||
])->with(['error' => Lang::get('lang.this_account_is_currently_inactive'),
|
||||
'referer' => $referer, ]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// try login
|
||||
$loginAttempts = 1;
|
||||
// If session has login attempts, retrieve attempts counter and attempts time
|
||||
if (\Session::has('loginAttempts')) {
|
||||
@@ -361,31 +387,19 @@ class AuthController extends Controller
|
||||
}
|
||||
// If auth ok, redirect to restricted area
|
||||
\Session::put('loginAttempts', $loginAttempts + 1);
|
||||
|
||||
if (Auth::Attempt([$field => $usernameinput, 'password' => $password], $request->has('remember'))) {
|
||||
if ($check_active->active == 0) {
|
||||
\Auth::logout();
|
||||
\Session::flush();
|
||||
|
||||
return \Redirect::route('otp-verification')
|
||||
->withInput($request->input())
|
||||
->with(['values' => $request->input(),
|
||||
'referer' => $referer,
|
||||
'name' => $check_active->first_name,
|
||||
'number' => $check_active->mobile,
|
||||
'code' => $check_active->country_code, ]);
|
||||
}
|
||||
if (Auth::user()->role == 'user') {
|
||||
if ($request->input('referer')) {
|
||||
return \Redirect::route($request->input('referer'));
|
||||
}
|
||||
|
||||
return \Redirect::route('/');
|
||||
} else {
|
||||
return redirect()->intended($this->redirectPath());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return redirect()->back()
|
||||
->withInput($request->only('email', 'remember'))
|
||||
->withErrors([
|
||||
|
Reference in New Issue
Block a user