Applied fixes from StyleCI
This commit is contained in:

committed by
StyleCI Bot

parent
b158c8e1ee
commit
a6a7c762dc
@@ -29,8 +29,8 @@ use Mail;
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class AuthController extends Controller {
|
||||
|
||||
class AuthController extends Controller
|
||||
{
|
||||
use AuthenticatesAndRegistersUsers;
|
||||
/* to redirect after login */
|
||||
|
||||
@@ -50,7 +50,8 @@ class AuthController extends Controller {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(PhpMailController $PhpMailController) {
|
||||
public function __construct(PhpMailController $PhpMailController)
|
||||
{
|
||||
$this->PhpMailController = $PhpMailController;
|
||||
SettingsController::smtp();
|
||||
$this->middleware('guest', ['except' => 'getLogout']);
|
||||
@@ -61,7 +62,8 @@ class AuthController extends Controller {
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function getRegister() {
|
||||
public function getRegister()
|
||||
{
|
||||
// Event for login
|
||||
\Event::fire(new \App\Events\FormRegisterEvent());
|
||||
if (Auth::user()) {
|
||||
@@ -83,7 +85,8 @@ class AuthController extends Controller {
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function postRegister(User $user, RegisterRequest $request) {
|
||||
public function postRegister(User $user, RegisterRequest $request)
|
||||
{
|
||||
// Event for login
|
||||
\Event::fire(new \App\Events\LoginEvent($request));
|
||||
$password = Hash::make($request->input('password'));
|
||||
@@ -96,28 +99,34 @@ class AuthController extends Controller {
|
||||
$code = str_random(60);
|
||||
$user->remember_token = $code;
|
||||
$user->save();
|
||||
$message12 = "";
|
||||
$var = $this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $name, 'email' => $request->input('email')], $message = ['subject' => 'Activate your Account', 'scenario' => 'registration'], $template_variables = ['user' => $name, 'email_address' => $request->input('email'), 'password_reset_link' => url('account/activate/' . $code)]);
|
||||
$message12 = '';
|
||||
$var = $this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $name, 'email' => $request->input('email')], $message = ['subject' => 'Activate your Account', 'scenario' => 'registration'], $template_variables = ['user' => $name, 'email_address' => $request->input('email'), 'password_reset_link' => url('account/activate/'.$code)]);
|
||||
if ($var == null) {
|
||||
$message12 = Lang::get('lang.failed_to_send_email_contact_administrator');
|
||||
|
||||
return redirect('home')->with('warning', $message12);
|
||||
} else {
|
||||
$message12 = Lang::get('lang.activate_your_account_click_on_Link_that_send_to_your_mail');
|
||||
}
|
||||
|
||||
return redirect('home')->with('success', $message12);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to activate account
|
||||
* Function to activate account.
|
||||
*
|
||||
* @param type $token
|
||||
*
|
||||
* @return type redirect
|
||||
*/
|
||||
public function accountActivate($token) {
|
||||
public function accountActivate($token)
|
||||
{
|
||||
$user = User::where('remember_token', '=', $token)->first();
|
||||
if ($user) {
|
||||
$user->active = 1;
|
||||
$user->remember_token = NULL;
|
||||
$user->remember_token = null;
|
||||
$user->save();
|
||||
|
||||
return redirect('/auth/login')->with('status', 'Acount activated. Login to start');
|
||||
} else {
|
||||
return redirect('/auth/login')->with('fails', 'Invalid Token');
|
||||
@@ -132,7 +141,8 @@ class AuthController extends Controller {
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function getMail($token, User $user) {
|
||||
public function getMail($token, User $user)
|
||||
{
|
||||
$user = $user->where('remember_token', $token)->where('active', 0)->first();
|
||||
if ($user) {
|
||||
$user->active = 1;
|
||||
@@ -149,7 +159,8 @@ class AuthController extends Controller {
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function getLogin() {
|
||||
public function getLogin()
|
||||
{
|
||||
if (Auth::user()) {
|
||||
if (Auth::user()->role == 'admin' || Auth::user()->role == 'agent') {
|
||||
return \Redirect::route('dashboard');
|
||||
@@ -168,7 +179,8 @@ class AuthController extends Controller {
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function postLogin(LoginRequest $request) {
|
||||
public function postLogin(LoginRequest $request)
|
||||
{
|
||||
// Set login attempts and login time
|
||||
$value = $_SERVER['REMOTE_ADDR'];
|
||||
$usernameinput = $request->input('email');
|
||||
@@ -187,7 +199,7 @@ class AuthController extends Controller {
|
||||
return redirect()->back()
|
||||
->withInput($request->only('email', 'remember'))
|
||||
->withErrors([
|
||||
'email' => $this->getFailedLoginMessage(),
|
||||
'email' => $this->getFailedLoginMessage(),
|
||||
'password' => $this->getFailedLoginMessage(),
|
||||
])->with('error', Lang::get('lang.this_account_is_currently_inactive'));
|
||||
}
|
||||
@@ -195,7 +207,7 @@ class AuthController extends Controller {
|
||||
return redirect()->back()
|
||||
->withInput($request->only('email', 'remember'))
|
||||
->withErrors([
|
||||
'email' => $this->getFailedLoginMessage(),
|
||||
'email' => $this->getFailedLoginMessage(),
|
||||
'password' => $this->getFailedLoginMessage(),
|
||||
])->with('error', Lang::get('lang.this_account_is_currently_inactive'));
|
||||
}
|
||||
@@ -238,7 +250,7 @@ class AuthController extends Controller {
|
||||
return redirect()->back()
|
||||
->withInput($request->only('email', 'remember'))
|
||||
->withErrors([
|
||||
'email' => $this->getFailedLoginMessage(),
|
||||
'email' => $this->getFailedLoginMessage(),
|
||||
'password' => $this->getFailedLoginMessage(),
|
||||
])->with('error', Lang::get('lang.invalid'));
|
||||
// Increment login attempts
|
||||
@@ -251,7 +263,8 @@ class AuthController extends Controller {
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function addLoginAttempt($value, $field) {
|
||||
public function addLoginAttempt($value, $field)
|
||||
{
|
||||
$result = DB::table('login_attempts')->where('IP', '=', $value)->first();
|
||||
$data = $result;
|
||||
$security = Security::whereId('1')->first();
|
||||
@@ -259,7 +272,7 @@ class AuthController extends Controller {
|
||||
if ($data) {
|
||||
$attempts = $data->Attempts + 1;
|
||||
if ($attempts == $apt) {
|
||||
$result = DB::select('UPDATE login_attempts SET Attempts=' . $attempts . ", LastLogin=NOW() WHERE IP = '$value' OR User = '$field'");
|
||||
$result = DB::select('UPDATE login_attempts SET Attempts='.$attempts.", LastLogin=NOW() WHERE IP = '$value' OR User = '$field'");
|
||||
} else {
|
||||
$result = DB::table('login_attempts')->where('IP', '=', $value)->orWhere('User', '=', $field)->update(['Attempts' => $attempts]);
|
||||
// $result = DB::select("UPDATE login_attempts SET Attempts=".$attempts." WHERE IP = '$value' OR User = '$field'");
|
||||
@@ -276,7 +289,8 @@ class AuthController extends Controller {
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function clearLoginAttempts($value, $field) {
|
||||
public function clearLoginAttempts($value, $field)
|
||||
{
|
||||
$data = DB::table('login_attempts')->where('IP', '=', $value)->orWhere('User', '=', $field)->update(['attempts' => '0']);
|
||||
|
||||
return $data;
|
||||
@@ -289,13 +303,14 @@ class AuthController extends Controller {
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function confirmIPAddress($value, $field) {
|
||||
public function confirmIPAddress($value, $field)
|
||||
{
|
||||
$security = Security::whereId('1')->first();
|
||||
$time = $security->lockout_period;
|
||||
$max_attempts = $security->backlist_threshold;
|
||||
$table = 'login_attempts';
|
||||
$result = DB::select('SELECT Attempts, (CASE when LastLogin is not NULL and DATE_ADD(LastLogin, INTERVAL ' . $time . ' MINUTE)>NOW() then 1 else 0 end) as Denied ' .
|
||||
' FROM ' . $table . " WHERE IP = '$value' OR User = '$field'");
|
||||
$result = DB::select('SELECT Attempts, (CASE when LastLogin is not NULL and DATE_ADD(LastLogin, INTERVAL '.$time.' MINUTE)>NOW() then 1 else 0 end) as Denied '.
|
||||
' FROM '.$table." WHERE IP = '$value' OR User = '$field'");
|
||||
$data = $result;
|
||||
//Verify that at least one login attempt is in database
|
||||
if (!$data) {
|
||||
@@ -319,8 +334,8 @@ class AuthController extends Controller {
|
||||
*
|
||||
* @return type string
|
||||
*/
|
||||
protected function getFailedLoginMessage() {
|
||||
protected function getFailedLoginMessage()
|
||||
{
|
||||
return Lang::get('lang.this_field_do_not_match_our_records');
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user