Files
firefly-iii/app/Http/Controllers/Auth/LoginController.php

80 lines
2.1 KiB
PHP
Raw Normal View History

2016-09-16 06:19:40 +02:00
<?php
2017-09-14 17:40:02 +02:00
declare(strict_types=1);
/**
* LoginController.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
*
* See the LICENSE file for details.
*/
2016-09-16 06:19:40 +02:00
namespace FireflyIII\Http\Controllers\Auth;
2017-09-14 16:13:25 +02:00
use FireflyConfig;
2016-09-16 06:19:40 +02:00
use FireflyIII\Http\Controllers\Controller;
2017-09-14 16:13:25 +02:00
use FireflyIII\User;
use Illuminate\Cookie\CookieJar;
2016-09-16 06:19:40 +02:00
use Illuminate\Foundation\Auth\AuthenticatesUsers;
2017-09-14 16:13:25 +02:00
use Illuminate\Http\Request;
2016-09-16 06:19:40 +02:00
class LoginController extends Controller
{
2017-09-09 22:03:27 +02:00
/*
|--------------------------------------------------------------------------
| 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.
|
*/
2016-09-16 06:19:40 +02:00
use AuthenticatesUsers;
/**
2017-09-09 22:03:27 +02:00
* Where to redirect users after login.
2016-09-16 06:19:40 +02:00
*
2017-09-09 22:03:27 +02:00
* @var string
2016-09-16 06:19:40 +02:00
*/
2017-09-09 22:03:27 +02:00
protected $redirectTo = '/home';
2016-09-16 07:22:57 +02:00
/**
2017-09-09 22:03:27 +02:00
* Create a new controller instance.
2016-12-28 18:49:30 +01:00
*
*/
2017-09-09 22:03:27 +02:00
public function __construct()
2016-12-28 18:49:30 +01:00
{
2017-09-12 18:24:42 +02:00
parent::__construct();
2017-09-09 22:03:27 +02:00
$this->middleware('guest')->except('logout');
2016-12-28 18:49:30 +01:00
}
2017-09-14 16:13:25 +02:00
/**
* Show the application's login form.
*
* @return \Illuminate\Http\Response
*/
public function showLoginForm(Request $request, CookieJar $cookieJar)
{
// forget 2fa cookie:
$cookie = $cookieJar->forever('twoFactorAuthenticated', 'false');
// is allowed to?
$singleUserMode = FireflyConfig::get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
$userCount = User::count();
$allowRegistration = true;
if ($singleUserMode === true && $userCount > 0) {
$allowRegistration = false;
}
$email = $request->old('email');
$remember = $request->old('remember');
return view('auth.login', compact('allowRegistration', 'email', 'remember'))->withCookie($cookie);
}
2016-09-16 06:19:40 +02:00
}