mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-26 01:36:43 +00:00
Merge pull request #465 from pixelfed/frontend-ui-refactor
Frontend ui refactor
This commit is contained in:
commit
a38ceb7df6
4 changed files with 76 additions and 13 deletions
|
@ -1,19 +1,16 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Events;
|
namespace App\Listeners;
|
||||||
|
|
||||||
use App\User;
|
use App\User;
|
||||||
use App\UserSetting;
|
use App\UserSetting;
|
||||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
use Illuminate\Foundation\Events\Dispatchable;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
|
|
||||||
class AuthLoginEvent
|
class AuthLogin
|
||||||
{
|
{
|
||||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new event instance.
|
* Create the event listener.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
@ -22,8 +19,15 @@ class AuthLoginEvent
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handle(User $user)
|
/**
|
||||||
|
* Handle the event.
|
||||||
|
*
|
||||||
|
* @param object $event
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle($event)
|
||||||
{
|
{
|
||||||
|
$user = $event->user;
|
||||||
if (empty($user->settings)) {
|
if (empty($user->settings)) {
|
||||||
$settings = new UserSetting();
|
$settings = new UserSetting();
|
||||||
$settings->user_id = $user->id;
|
$settings->user_id = $user->id;
|
44
app/Listeners/LogFailedLogin.php
Normal file
44
app/Listeners/LogFailedLogin.php
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Listeners;
|
||||||
|
|
||||||
|
use App\AccountLog;
|
||||||
|
use App\User;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
|
||||||
|
class LogFailedLogin
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create the event listener.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the event.
|
||||||
|
*
|
||||||
|
* @param object $event
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle($event)
|
||||||
|
{
|
||||||
|
$user = $event->user;
|
||||||
|
$request = request();
|
||||||
|
|
||||||
|
$log = new AccountLog();
|
||||||
|
$log->user_id = $user->id;
|
||||||
|
$log->item_id = $user->id;
|
||||||
|
$log->item_type = 'App\User';
|
||||||
|
$log->action = 'auth.failed';
|
||||||
|
$log->message = 'Failed login attempt';
|
||||||
|
$log->link = null;
|
||||||
|
$log->ip_address = $request->ip();
|
||||||
|
$log->user_agent = $request->userAgent();
|
||||||
|
$log->save();
|
||||||
|
}
|
||||||
|
}
|
|
@ -205,4 +205,19 @@ class Profile extends Model
|
||||||
{
|
{
|
||||||
return $this->hasMany(Media::class, 'profile_id');
|
return $this->hasMany(Media::class, 'profile_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function inboxUrl()
|
||||||
|
{
|
||||||
|
return $this->inbox_url ?? $this->permalink('/inbox');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function outboxUrl()
|
||||||
|
{
|
||||||
|
return $this->outbox_url ?? $this->permalink('/outbox');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function sharedInbox()
|
||||||
|
{
|
||||||
|
return $this->sharedInbox ?? $this->inboxUrl();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,11 +13,11 @@ class EventServiceProvider extends ServiceProvider
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $listen = [
|
protected $listen = [
|
||||||
'App\Events\Event' => [
|
'Illuminate\Auth\Events\Login' => [
|
||||||
'App\Listeners\EventListener',
|
'App\Listeners\AuthLogin',
|
||||||
],
|
],
|
||||||
'auth.login' => [
|
'Illuminate\Auth\Events\Failed' => [
|
||||||
'App\Events\AuthLoginEvent',
|
'App\Listeners\LogFailedLogin',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue