/** * Handle the command. * @param object $command * @return void */ public function handle($command) { $user = $this->model->login($command->email, $command->password); $this->dispatchEventsFor($user); $this->repository->login($command); return $user; }
/** * Handle the command. * * @param object $command * @return void */ public function handle($command) { $activation_code = Shorten::generateHash(40); $user = $this->model->register($command->username, $command->email, $command->password, $activation_code); $this->repository->save($user); $this->dispatchEventsFor($user); return $user; }
/** * Handle the command. * @param object $command * @throws InvalidConfirmationCodeException * @return void */ public function handle($command) { $user = User::findOrFail($command->id); if ($command->code !== $user->activation_code) { throw new InvalidConfirmationCodeException(); } $user->activated = 1; $user->activation_code = null; $user->save(); }
/** * Login user * @param $command * @throws UserLoginException * @return mixed|void */ public function login($command) { $user = User::whereEmail($command->email)->firstOrFail(); if ($user->activated == 0) { throw new UserLoginException('You must activate your account before signing in.'); } $credentials = ['email' => $command->email, 'password' => $command->password, 'activated' => 1]; if (!\Auth::attempt($credentials)) { throw new UserLoginException('Could not sign you in. Validate your credentials and try again.'); } }
/** * Retrieve all links belonging to a user * @param User $user * @return mixed */ public function getAllUserLinks(User $user) { return $user->links()->with('user')->get(); }