mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-18 12:28:46 +00:00
Combination of initial files and some new code for login and user registration.
This commit is contained in:
20
app/lib/Firefly/Storage/StorageServiceProvider.php
Normal file
20
app/lib/Firefly/Storage/StorageServiceProvider.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
namespace Firefly\Storage;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class StorageServiceProvider extends ServiceProvider
|
||||
{
|
||||
|
||||
|
||||
// Triggered automatically by Laravel
|
||||
public function register()
|
||||
{
|
||||
// storage:
|
||||
$this->app->bind(
|
||||
'Firefly\Storage\User\UserRepositoryInterface',
|
||||
'Firefly\Storage\User\EloquentUserRepository'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
44
app/lib/Firefly/Storage/User/EloquentUserRepository.php
Normal file
44
app/lib/Firefly/Storage/User/EloquentUserRepository.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Firefly\Storage\User;
|
||||
|
||||
class EloquentUserRepository implements UserRepositoryInterface
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public function register()
|
||||
{
|
||||
$user = new \User;
|
||||
$user->email = \Input::get('email');
|
||||
$user->migrated = 0;
|
||||
$user->verification = \Str::random(32);
|
||||
$user->password = \Hash::make(\Str::random(12));
|
||||
|
||||
if (!$user->isValid()) {
|
||||
\Log::error('Invalid user');
|
||||
\Session::flash('error', 'Input invalid, please try again.');
|
||||
return false;
|
||||
}
|
||||
$user->save();
|
||||
return $user;
|
||||
}
|
||||
|
||||
public function auth()
|
||||
{
|
||||
$user = \User::where('email', \Input::get('email'))->first();
|
||||
if (!is_null($user)) {
|
||||
if (\Hash::check(\Input::get('password'), $user->password)) {
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function findByVerification($verification)
|
||||
{
|
||||
return \User::where('verification', $verification)->first();
|
||||
}
|
||||
|
||||
}
|
||||
15
app/lib/Firefly/Storage/User/UserRepositoryInterface.php
Normal file
15
app/lib/Firefly/Storage/User/UserRepositoryInterface.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Firefly\Storage\User;
|
||||
|
||||
|
||||
interface UserRepositoryInterface
|
||||
{
|
||||
public function register();
|
||||
public function auth();
|
||||
|
||||
public function findByVerification($verification);
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user