Fix commonmark error.

This commit is contained in:
James Cole
2021-08-02 20:30:26 +02:00
parent f7f296c674
commit e04a71738d
5 changed files with 30 additions and 34 deletions

View File

@@ -30,7 +30,6 @@ use Illuminate\Contracts\View\Factory;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Password;
use Illuminate\View\View;
use Log;
@@ -93,15 +92,12 @@ class ForgotPasswordController extends Controller
// We will send the password reset link to this user. Once we have attempted
// to send the link, we will examine the response then see the message we
// need to show to the user. Finally, we'll send out a proper response.
$response = $this->broker()->sendResetLink(
$request->only('email')
);
$this->broker()->sendResetLink($request->only('email'));
if ($response === Password::RESET_LINK_SENT) {
return back()->with('status', trans($response));
}
// always send the same response:
$response = trans('firefly.forgot_password_response');
return back()->withErrors(['email' => trans($response)]);
return back()->with('status', trans($response));
}
/**

View File

@@ -69,6 +69,7 @@ class RegisterController extends Controller
if ('eloquent' !== $loginProvider || 'web' !== $authGuard) {
throw new FireflyException('Using external identity provider. Cannot continue.');
}
}
/**
@@ -84,21 +85,19 @@ class RegisterController extends Controller
{
// is allowed to?
$allowRegistration = true;
$loginProvider = config('firefly.login_provider');
$singleUserMode = app('fireflyconfig')->get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
$userCount = User::count();
if (true === $singleUserMode && $userCount > 0 && 'eloquent' === $loginProvider) {
$guard = config('auth.defaults.guard');
if (true === $singleUserMode && $userCount > 0 && 'ldap' !== $guard) {
$allowRegistration = false;
}
if ('eloquent' !== $loginProvider) {
if ('ldap' === $guard) {
$allowRegistration = false;
}
if (false === $allowRegistration) {
$message = 'Registration is currently not available.';
return prefixView('error', compact('message'));
throw new FireflyException('Registration is currently not available :(');
}
$this->validator($request->all())->validate();
@@ -126,21 +125,21 @@ class RegisterController extends Controller
public function showRegistrationForm(Request $request)
{
$allowRegistration = true;
$loginProvider = config('firefly.login_provider');
$isDemoSite = app('fireflyconfig')->get('is_demo_site', config('firefly.configuration.is_demo_site'))->data;
$singleUserMode = app('fireflyconfig')->get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
$userCount = User::count();
$pageTitle = (string)trans('firefly.register_page_title');
$guard = config('auth.defaults.guard');
if (true === $isDemoSite) {
$allowRegistration = false;
}
if (true === $singleUserMode && $userCount > 0 && 'eloquent' === $loginProvider) {
if (true === $singleUserMode && $userCount > 0 && 'ldap' !== $guard) {
$allowRegistration = false;
}
if ('eloquent' !== $loginProvider) {
if ('ldap' === $guard) {
$allowRegistration = false;
}

View File

@@ -87,7 +87,6 @@ class ResetPasswordController extends Controller
return prefixView('error', compact('message'));
}
$rules = [
'token' => 'required',
'email' => 'required|email',

View File

@@ -28,7 +28,7 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\Support\Search\OperatorQuerySearch;
use League\CommonMark\CommonMarkConverter;
use League\CommonMark\Environment;
use League\CommonMark\Environment\Environment;
use League\CommonMark\Extension\GithubFlavoredMarkdownExtension;
use Route;
use Twig\Extension\AbstractExtension;
@@ -203,8 +203,10 @@ class General extends AbstractExtension
protected function markdown(): TwigFilter
{
return new TwigFilter(
'markdown',
'markdown',
static function (string $text): string {
$environment = Environment::createCommonMarkEnvironment();
$environment->addExtension(new GithubFlavoredMarkdownExtension());
@@ -355,7 +357,7 @@ class General extends AbstractExtension
/**
* @return TwigFunction
* See reference nr. 43
* See reference nr. 43
*/
protected function getMetaField(): TwigFunction
{