Blame view
app/Listeners/AuthEventListener.php
1.45 KB
e77200db5 Initial commit |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
<?php namespace FootyRoom\Listeners; use FootyRoom\User\User; use FootyRoom\Config; use Illuminate\Http\Request; use Illuminate\Contracts\Events\Dispatcher; use FootyRoom\Repositories\UserRepository; class AuthEventListener { /** * Create a new AuthEventListener instance. * * @param \Illuminate\Contracts\Config\Repository $config */ public function __construct(Config $config, UserRepository $userRepo) { $this->config = $config; $this->userRepo = $userRepo; } /** * Removes newborn status if 10 days have passed since the user activated * his account, i.e. officially registered. * * @param \FootyRoom\User\User $user * * @return void */ public function newbornCheck(User $user) { if ($user->isNewborn() && $user->readyForBirth()) { $user->birth(); $this->userRepo->update($user->getUserId(), ['status' => $user->getStatus()]); } } /** * Records login if configured to record. * * @param \FootyRoom\User\User $user * @param \Illuminate\Http\Request $request * * @return void */ public function recordLogin(User $user, Request $request) { if ($this->config->get('recordLogins')) { $this->userRepo->recordLogin( $user->getUserId(), $request->ip(), $request->session()->get('tracker') ); } } } |