Add new version in repository
This commit is contained in:
@@ -3,38 +3,49 @@
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Repositories\Layout;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Login Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller handles authenticating users for the application and
|
||||
| redirecting them to your home screen. The controller uses a trait
|
||||
| to conveniently provide its functionality to your applications.
|
||||
|
|
||||
*/
|
||||
|
||||
use AuthenticatesUsers;
|
||||
protected $redirectTo = '/';
|
||||
|
||||
/**
|
||||
* Where to redirect users after login.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = RouteServiceProvider::HOME;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest')->except('logout');
|
||||
$this->middleware('guest:web')->except('logout');
|
||||
}
|
||||
|
||||
public function showLoginForm()
|
||||
{
|
||||
$data = \App\Repositories\Config::init();
|
||||
return view('auth.login', $data);
|
||||
}
|
||||
|
||||
public function authenticated(Request $request, $user)
|
||||
{
|
||||
$request->session()->forget('password_expired_id');
|
||||
|
||||
if ($user->passwordSecurity->password_expiry_days > 0) {
|
||||
$password_updated_at = $user->passwordSecurity->password_updated_at;
|
||||
$password_expiry_days = $user->passwordSecurity->password_expiry_days;
|
||||
$password_expiry_at = Carbon::parse($password_updated_at)->addDays($password_expiry_days);
|
||||
if ($password_expiry_at->lessThan(Carbon::now())) {
|
||||
$request->session()->put('password_expired_id', $user->id);
|
||||
auth()->logout();
|
||||
return redirect('/reset-password')->with('message', "Your password is expired. You need to change your password.");
|
||||
}
|
||||
}
|
||||
|
||||
return redirect()->intended($this->redirectPath());
|
||||
}
|
||||
|
||||
public function username()
|
||||
{
|
||||
return 'username';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user