mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Various changes to support the removed old code.
This commit is contained in:
parent
f08fcc36fb
commit
5cb9907bf8
@ -19,14 +19,6 @@ class HomeController extends BaseController
|
||||
$this->_preferences = $preferences;
|
||||
}
|
||||
|
||||
public function jobDev()
|
||||
{
|
||||
$fullName = storage_path() . DIRECTORY_SEPARATOR . 'firefly-export-2014-07-23.json';
|
||||
\Log::notice('Pushed start job.');
|
||||
Queue::push('Firefly\Queue\Import@start', ['file' => $fullName, 'user' => 1]);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
|
@ -1,8 +1,5 @@
|
||||
<?php
|
||||
|
||||
use Firefly\Helper\Email\EmailHelperInterface as EHI;
|
||||
use Firefly\Storage\User\UserRepositoryInterface as URI;
|
||||
|
||||
/**
|
||||
* Class UserController
|
||||
*/
|
||||
@ -11,15 +8,9 @@ class UserController extends BaseController
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param URI $user
|
||||
* @param EHI $email
|
||||
*/
|
||||
public function __construct(URI $user, EHI $email)
|
||||
public function __construct()
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->email = $email;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -84,14 +75,25 @@ class UserController extends BaseController
|
||||
if (Config::get('auth.allow_register') !== true) {
|
||||
return View::make('error')->with('message', 'Not possible');
|
||||
}
|
||||
$user = $this->user->register(Input::all());
|
||||
|
||||
/** @var \FireflyIII\Database\User $repository */
|
||||
$repository = App::make('FireflyIII\Database\User');
|
||||
|
||||
/** @var \FireflyIII\Shared\Mail\RegistrationInterface $email */
|
||||
$email = App::make('FireflyIII\Shared\Mail\RegistrationInterface');
|
||||
|
||||
$user = $repository->register(Input::all());
|
||||
|
||||
|
||||
|
||||
//$user = $this->user->register(Input::all());
|
||||
if ($user) {
|
||||
if (Config::get('auth.verify_mail') === true) {
|
||||
$this->email->sendVerificationMail($user);
|
||||
$email->sendVerificationMail($user);
|
||||
|
||||
return View::make('user.verification-pending');
|
||||
}
|
||||
$this->email->sendPasswordMail($user);
|
||||
$email->sendPasswordMail($user);
|
||||
|
||||
return View::make('user.registered');
|
||||
}
|
||||
@ -130,18 +132,26 @@ class UserController extends BaseController
|
||||
*/
|
||||
public function postRemindme()
|
||||
{
|
||||
$user = $this->user->findByEmail(Input::get('email'));
|
||||
|
||||
/** @var \FireflyIII\Database\User $repository */
|
||||
$repository = App::make('FireflyIII\Database\User');
|
||||
|
||||
/** @var \FireflyIII\Shared\Mail\RegistrationInterface $email */
|
||||
$email = App::make('FireflyIII\Shared\Mail\RegistrationInterface');
|
||||
|
||||
|
||||
$user = $repository->findByEmail(Input::get('email'));
|
||||
if (!$user) {
|
||||
Session::flash('error', 'No good!');
|
||||
|
||||
return View::make('user.remindme');
|
||||
}
|
||||
if (Config::get('auth.verify_reset') === true) {
|
||||
$this->email->sendResetVerification($user);
|
||||
$email->sendResetVerification($user);
|
||||
|
||||
return View::make('user.verification-pending');
|
||||
}
|
||||
$this->email->sendPasswordMail($user);
|
||||
$email->sendPasswordMail($user);
|
||||
|
||||
return View::make('user.registered');
|
||||
|
||||
@ -156,9 +166,16 @@ class UserController extends BaseController
|
||||
*/
|
||||
public function reset($reset)
|
||||
{
|
||||
$user = $this->user->findByReset($reset);
|
||||
|
||||
/** @var \FireflyIII\Database\User $repository */
|
||||
$repository = App::make('FireflyIII\Database\User');
|
||||
|
||||
/** @var \FireflyIII\Shared\Mail\RegistrationInterface $email */
|
||||
$email = App::make('FireflyIII\Shared\Mail\RegistrationInterface');
|
||||
|
||||
$user = $repository->findByReset($reset);
|
||||
if ($user) {
|
||||
$this->email->sendPasswordMail($user);
|
||||
$email->sendPasswordMail($user);
|
||||
|
||||
return View::make('user.registered');
|
||||
}
|
||||
|
57
app/lib/FireflyIII/Database/User.php
Normal file
57
app/lib/FireflyIII/Database/User.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace FireflyIII\Database;
|
||||
|
||||
|
||||
/**
|
||||
* Class User
|
||||
* @package FireflyIII\Database
|
||||
*/
|
||||
class User
|
||||
{
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @return bool|\User
|
||||
*/
|
||||
public function register(array $data)
|
||||
{
|
||||
$user = new \User;
|
||||
$user->email = isset($data['email']) ? $data['email'] : null;
|
||||
$user->migrated = 0;
|
||||
$user->reset = \Str::random(32);
|
||||
$user->password = \Hash::make(\Str::random(12));
|
||||
|
||||
if (!$user->save()) {
|
||||
\Log::error('Invalid user with data: ' . isset($data['email']) ? $data['email'] : '(no email!)');
|
||||
\Session::flash('error', 'Input invalid, please try again: ' . $user->errors()->first());
|
||||
|
||||
return false;
|
||||
}
|
||||
$user->save();
|
||||
|
||||
return $user;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $mail
|
||||
*
|
||||
* @return null|User
|
||||
*/
|
||||
public function findByEmail($mail)
|
||||
{
|
||||
return \User::where('email', $mail)->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $reset
|
||||
*
|
||||
* @return null|User
|
||||
*/
|
||||
public function findByReset($reset)
|
||||
{
|
||||
return \User::where('reset', $reset)->first();
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace FireflyIII;
|
||||
|
||||
use FireflyIII\Shared\Validation\FireflyValidator;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
/**
|
||||
@ -11,6 +12,14 @@ use Illuminate\Support\ServiceProvider;
|
||||
class FF3ServiceProvider extends ServiceProvider
|
||||
{
|
||||
|
||||
public function boot()
|
||||
{
|
||||
$this->app->validator->resolver(
|
||||
function ($translator, $data, $rules, $messages) {
|
||||
return new FireflyValidator($translator, $data, $rules, $messages);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggered automatically by Laravel
|
||||
@ -23,6 +32,9 @@ class FF3ServiceProvider extends ServiceProvider
|
||||
// preferences:
|
||||
$this->app->bind('FireflyIII\Shared\Preferences\PreferencesInterface', 'FireflyIII\Shared\Preferences\Preferences');
|
||||
|
||||
// registration and user mail:
|
||||
$this->app->bind('FireflyIII\Shared\Mail\RegistrationInterface', 'FireflyIII\Shared\Mail\Registration');
|
||||
|
||||
}
|
||||
|
||||
}
|
77
app/lib/FireflyIII/Shared/Mail/Registration.php
Normal file
77
app/lib/FireflyIII/Shared/Mail/Registration.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
namespace FireflyIII\Shared\Mail;
|
||||
|
||||
/**
|
||||
* Class Registration
|
||||
*
|
||||
* @package FireflyIII\Shared\Mail
|
||||
*/
|
||||
class Registration implements RegistrationInterface
|
||||
{
|
||||
/**
|
||||
* @param \User $user
|
||||
*
|
||||
* @return mixed|void
|
||||
*/
|
||||
public function sendVerificationMail(\User $user)
|
||||
{
|
||||
|
||||
$reset = \Str::random(32);
|
||||
$user->reset = $reset;
|
||||
$user->forceSave();
|
||||
$email = $user->email;
|
||||
$data = ['reset' => $reset];
|
||||
|
||||
\Mail::send(
|
||||
['emails.user.verify-html', 'emails.user.verify-text'], $data, function ($message) use ($email) {
|
||||
$message->to($email, $email)->subject('Verify your e-mail address.');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \User $user
|
||||
*
|
||||
* @return mixed|void
|
||||
*/
|
||||
public function sendPasswordMail(\User $user)
|
||||
{
|
||||
|
||||
$password = \Str::random(12);
|
||||
$user->password = $password;
|
||||
$user->reset = \Str::random(32); // new one.
|
||||
$user->forceSave();
|
||||
$email = $user->email;
|
||||
|
||||
|
||||
$data = ['password' => $password];
|
||||
\Mail::send(
|
||||
['emails.user.register-html', 'emails.user.register-text'], $data, function ($message) use ($email) {
|
||||
$message->to($email, $email)->subject('Welcome to Firefly!');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \User $user
|
||||
*
|
||||
* @return mixed|void
|
||||
*/
|
||||
public function sendResetVerification(\User $user)
|
||||
{
|
||||
$reset = \Str::random(32);
|
||||
$user->reset = $reset;
|
||||
$user->forceSave();
|
||||
$email = $user->email;
|
||||
|
||||
$data = ['reset' => $reset];
|
||||
\Mail::send(
|
||||
['emails.user.remindme-html', 'emails.user.remindme-text'], $data, function ($message) use ($email) {
|
||||
$message->to($email, $email)->subject('Forgot your password?');
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
34
app/lib/FireflyIII/Shared/Mail/RegistrationInterface.php
Normal file
34
app/lib/FireflyIII/Shared/Mail/RegistrationInterface.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace FireflyIII\Shared\Mail;
|
||||
|
||||
/**
|
||||
* Interface RegistrationInterface
|
||||
*
|
||||
* @package FireflyIII\Shared\Mail
|
||||
*/
|
||||
interface RegistrationInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @param \User $user
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function sendVerificationMail(\User $user);
|
||||
|
||||
/**
|
||||
* @param \User $user
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function sendPasswordMail(\User $user);
|
||||
|
||||
/**
|
||||
* @param \User $user
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function sendResetVerification(\User $user);
|
||||
|
||||
}
|
@ -29,8 +29,8 @@ class Filter
|
||||
if (!is_null(\Session::get('range'))) {
|
||||
$range = \Session::get('range');
|
||||
} else {
|
||||
/** @noinspection PhpUndefinedClassInspection */
|
||||
$preferences = \App::make('Firefly\Helper\Preferences\PreferencesHelperInterface');
|
||||
/** @var \FireflyIII\Shared\Preferences\PreferencesInterface $preferences */
|
||||
$preferences = \App::make('FireflyIII\Shared\Preferences\PreferencesInterface');
|
||||
$viewRange = $preferences->get('viewRange', '1M');
|
||||
|
||||
// default range:
|
||||
|
22
app/lib/FireflyIII/Shared/Validation/FireflyValidator.php
Normal file
22
app/lib/FireflyIII/Shared/Validation/FireflyValidator.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
namespace FireflyIII\Shared\Validation;
|
||||
|
||||
use Illuminate\Validation\Validator;
|
||||
|
||||
/**
|
||||
* Class FireflyValidator
|
||||
*
|
||||
* @package FireflyIII\Shared\Validation
|
||||
*/
|
||||
class FireflyValidator extends Validator
|
||||
{
|
||||
public function validateAlphabasic($attribute, $value, $parameters)
|
||||
{
|
||||
$pattern = '/[^[:alnum:]_\-\.\& \(\)\'"]/iu';
|
||||
if (preg_match($pattern, $value)) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace FireflyIII\Shared\Validation;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
/**
|
||||
* Class ValidationServiceProvider
|
||||
* @package FireflyIII\Shared\Validation
|
||||
*/
|
||||
class ValidationServiceProvider extends ServiceProvider
|
||||
{
|
||||
public function boot()
|
||||
{
|
||||
$this->app->validator->resolver(
|
||||
function ($translator, $data, $rules, $messages) {
|
||||
return new FireflyValidator($translator, $data, $rules, $messages);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public function register()
|
||||
{
|
||||
}
|
||||
}
|
@ -7,24 +7,13 @@
|
||||
<p class="lead">Welcome to Firefly III.</p>
|
||||
|
||||
<p>
|
||||
To get get started, choose below:
|
||||
Create a new asset account to get started.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-6 col-md-6 col-sm-12">
|
||||
<h2><a href="{{route('migrate.index')}}">Migrate from Firefly II</a></h2>
|
||||
|
||||
<p>
|
||||
Use this option if you have a JSON file from your current Firefly II installation.
|
||||
</p>
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-12">
|
||||
<h2><a href="{{route('accounts.create','asset')}}">Start from scratch</a></h2>
|
||||
|
||||
<p>
|
||||
Use this option if you are new to Firefly (III).
|
||||
</p>
|
||||
</div>
|
||||
@else
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user