Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class UserLoginService
- {
- protected $notis;
- public function execute($request)
- {
- $email = $request->getEmail();
- $password = $request->getPassword();
- $autenticated = AuthService::autenticate(
- $email,
- $password
- );
- if ($autenticated) {
- $userRepo = new UserRepository();
- $user = $userRepo->findByEmail($email);
- $this->notis = $user->getNotifications();
- if (!$user->isBlocked()) {
- $mail = new Zend_Mail();
- $mail->setTo($email);
- $mail->setBody('Sesión iniciada');
- $email->send();
- Events:trigger(
- 'user.logged',
- array('user_id' => $user->getId())
- );
- } else {
- throw new AuthException('User is blocked');
- }
- } else {
- throw new AuthException();
- }
- }
- public function getNotifications()
- {
- return $this->notis;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement