2014-06-29 15:12:33 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
namespace Firefly\Storage\User;
|
|
|
|
|
|
|
|
class EloquentUserRepository implements UserRepositoryInterface
|
|
|
|
{
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-07-02 16:12:31 -05:00
|
|
|
public function register($array)
|
2014-06-29 15:12:33 -05:00
|
|
|
{
|
|
|
|
$user = new \User;
|
2014-07-03 01:30:12 -05:00
|
|
|
$user->email = isset($array['email']) ? $array['email'] : null;
|
2014-06-29 15:12:33 -05:00
|
|
|
$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;
|
|
|
|
}
|
|
|
|
|
2014-07-02 16:12:31 -05:00
|
|
|
public function auth($array)
|
2014-06-29 15:12:33 -05:00
|
|
|
{
|
2014-07-02 16:12:31 -05:00
|
|
|
$user = \User::where('email', $array['email'])->first();
|
2014-06-29 15:12:33 -05:00
|
|
|
if (!is_null($user)) {
|
2014-07-02 16:12:31 -05:00
|
|
|
if (\Hash::check($array['password'], $user->password)) {
|
2014-06-29 15:12:33 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function findByVerification($verification)
|
|
|
|
{
|
|
|
|
return \User::where('verification', $verification)->first();
|
|
|
|
}
|
|
|
|
|
2014-06-30 00:26:38 -05:00
|
|
|
public function findByReset($reset)
|
|
|
|
{
|
|
|
|
return \User::where('reset', $reset)->first();
|
|
|
|
}
|
2014-07-02 16:12:31 -05:00
|
|
|
|
2014-06-30 00:26:38 -05:00
|
|
|
public function findByEmail($email)
|
|
|
|
{
|
|
|
|
return \User::where('email', $email)->first();
|
|
|
|
}
|
|
|
|
|
2014-06-29 15:12:33 -05:00
|
|
|
}
|