mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-16 09:22:33 +00:00
Initial code for LDAP authentication.
This commit is contained in:
@@ -41,6 +41,7 @@ use FireflyIII\User;
|
||||
use Google2FA;
|
||||
use Hash;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use Laravel\Passport\ClientRepository;
|
||||
use Log;
|
||||
@@ -71,6 +72,7 @@ class ProfileController extends Controller
|
||||
return $next($request);
|
||||
}
|
||||
);
|
||||
|
||||
$this->middleware(IsDemoUser::class)->except(['index']);
|
||||
$this->middleware(IsSandStormUser::class)->except('index');
|
||||
}
|
||||
@@ -80,8 +82,15 @@ class ProfileController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function changeEmail()
|
||||
public function changeEmail(Request $request)
|
||||
{
|
||||
$loginProvider = config('firefly.login_provider');
|
||||
if ('eloquent' !== $loginProvider) {
|
||||
$request->session()->flash('error', trans('firefly.login_provider_local_only', ['login_provider' => $loginProvider]));
|
||||
|
||||
return redirect(route('profile.index'));
|
||||
}
|
||||
|
||||
$title = auth()->user()->email;
|
||||
$email = auth()->user()->email;
|
||||
$subTitle = (string)trans('firefly.change_your_email');
|
||||
@@ -95,8 +104,15 @@ class ProfileController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function changePassword()
|
||||
public function changePassword(Request $request)
|
||||
{
|
||||
$loginProvider = config('firefly.login_provider');
|
||||
if ('eloquent' !== $loginProvider) {
|
||||
$request->session()->flash('error', trans('firefly.login_provider_local_only', ['login_provider' => $loginProvider]));
|
||||
|
||||
return redirect(route('profile.index'));
|
||||
}
|
||||
|
||||
$title = auth()->user()->email;
|
||||
$subTitle = (string)trans('firefly.change_your_password');
|
||||
$subTitleIcon = 'fa-key';
|
||||
@@ -132,6 +148,10 @@ class ProfileController extends Controller
|
||||
*/
|
||||
public function confirmEmailChange(UserRepositoryInterface $repository, string $token)
|
||||
{
|
||||
$loginProvider = config('firefly.login_provider');
|
||||
if ('eloquent' !== $loginProvider) {
|
||||
throw new FireflyException('Cannot confirm email change when authentication provider is not local.');
|
||||
}
|
||||
// find preference with this token value.
|
||||
/** @var Collection $set */
|
||||
$set = app('preferences')->findByName('email_change_confirm_token');
|
||||
@@ -163,8 +183,12 @@ class ProfileController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function deleteAccount()
|
||||
public function deleteAccount(Request $request)
|
||||
{
|
||||
$loginProvider = config('firefly.login_provider');
|
||||
if ('eloquent' !== $loginProvider) {
|
||||
$request->session()->flash('warning', trans('firefly.delete_local_info_only', ['login_provider' => $loginProvider]));
|
||||
}
|
||||
$title = auth()->user()->email;
|
||||
$subTitle = (string)trans('firefly.delete_account');
|
||||
$subTitleIcon = 'fa-trash';
|
||||
@@ -216,6 +240,7 @@ class ProfileController extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$loginProvider = config('firefly.login_provider');
|
||||
// check if client token thing exists (default one)
|
||||
$count = DB::table('oauth_clients')
|
||||
->where('personal_access_client', 1)
|
||||
@@ -241,7 +266,7 @@ class ProfileController extends Controller
|
||||
$accessToken = app('preferences')->set('access_token', $token);
|
||||
}
|
||||
|
||||
return view('profile.index', compact('subTitle', 'userId', 'accessToken', 'enabled2FA'));
|
||||
return view('profile.index', compact('subTitle', 'userId', 'accessToken', 'enabled2FA', 'loginProvider'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -254,6 +279,13 @@ class ProfileController extends Controller
|
||||
*/
|
||||
public function postChangeEmail(EmailFormRequest $request, UserRepositoryInterface $repository)
|
||||
{
|
||||
$loginProvider = config('firefly.login_provider');
|
||||
if ('eloquent' !== $loginProvider) {
|
||||
$request->session()->flash('error', trans('firefly.login_provider_local_only', ['login_provider' => $loginProvider]));
|
||||
|
||||
return redirect(route('profile.index'));
|
||||
}
|
||||
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
$newEmail = $request->string('email');
|
||||
@@ -299,6 +331,13 @@ class ProfileController extends Controller
|
||||
*/
|
||||
public function postChangePassword(ProfileFormRequest $request, UserRepositoryInterface $repository)
|
||||
{
|
||||
$loginProvider = config('firefly.login_provider');
|
||||
if ('eloquent' !== $loginProvider) {
|
||||
$request->session()->flash('error', trans('firefly.login_provider_local_only', ['login_provider' => $loginProvider]));
|
||||
|
||||
return redirect(route('profile.index'));
|
||||
}
|
||||
|
||||
// the request has already validated both new passwords must be equal.
|
||||
$current = $request->get('current_password');
|
||||
$new = $request->get('new_password');
|
||||
@@ -396,6 +435,11 @@ class ProfileController extends Controller
|
||||
*/
|
||||
public function undoEmailChange(UserRepositoryInterface $repository, string $token, string $hash)
|
||||
{
|
||||
$loginProvider = config('firefly.login_provider');
|
||||
if ('eloquent' !== $loginProvider) {
|
||||
throw new FireflyException('Cannot confirm email change when authentication provider is not local.');
|
||||
}
|
||||
|
||||
// find preference with this token value.
|
||||
$set = app('preferences')->findByName('email_change_undo_token');
|
||||
$user = null;
|
||||
|
Reference in New Issue
Block a user