Advertisement
Guest User

Untitled

a guest
Mar 13th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. <?php
  2. class UserLoginService
  3. {
  4. protected $notis;
  5.  
  6. public function execute($request)
  7. {
  8. $email = $request->getEmail();
  9. $password = $request->getPassword();
  10.  
  11. $autenticated = AuthService::autenticate(
  12. $email,
  13. $password
  14. );
  15.  
  16. if ($autenticated) {
  17.  
  18. $userRepo = new UserRepository();
  19. $user = $userRepo->findByEmail($email);
  20. $this->notis = $user->getNotifications();
  21.  
  22. if (!$user->isBlocked()) {
  23. $mail = new Zend_Mail();
  24. $mail->setTo($email);
  25. $mail->setBody('Sesión iniciada');
  26. $email->send();
  27.  
  28. Events:trigger(
  29. 'user.logged',
  30. array('user_id' => $user->getId())
  31. );
  32.  
  33. } else {
  34. throw new AuthException('User is blocked');
  35. }
  36.  
  37. } else {
  38. throw new AuthException();
  39. }
  40. }
  41.  
  42. public function getNotifications()
  43. {
  44. return $this->notis;
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement