Ejemplo n.º 1
0
 public function loginAction()
 {
     $request = $this->getRequest();
     if ($request->isPost()) {
         $email = $request->getPost('user-email', false);
         $password = $request->getPost('user-password', false);
         $empty_obj = new NotEmpty();
         if (!$empty_obj->isValid($email) || !$email) {
             throw new \RuntimeException("El usuario no es válido");
         }
         if (!$empty_obj->isValid($password) || !$password) {
             throw new \RuntimeException("La contraseña no es válida");
         }
         $password = Encrypt::encrypt(trim($password), trim($email));
         $email = md5(trim($email));
         $user_obj = $this->em->getRepository('Application\\Entity\\WebsiteTbSecurityUser')->findOneBySusvLogin($email);
         if (!$empty_obj->isValid($user_obj)) {
             throw new \RuntimeException("El ussuario no es válido");
         }
         if ($user_obj->getSusvPassword() !== $password) {
             throw new \RuntimeException("La contraseña no es válida");
         }
         $user = array('userId' => $user_obj->getSusi()->getSusiId(), 'userEntity' => $user_obj->getSeni()->getSeniId(), 'userName' => $user_obj->getSusi()->getSudvName(), 'userEmail' => $user_obj->getSusvLoginname());
         $this->getServiceLocator()->get('AuthService')->setStorage($this->getSessionStorage());
         $this->getServiceLocator()->get('AuthService')->getStorage()->write($user);
         return $this->redirect()->toRoute('dashboard');
     }
 }
Ejemplo n.º 2
0
 public function editAction()
 {
     if ($this->userId != 1) {
         return $this->redirect()->toRoute('dashboard');
     }
     $request = $this->getRequest();
     if ($request->isPost()) {
         $notEmpty_obj = new NotEmpty();
         if ($notEmpty_obj->isValid($request->getPost('susvPassword'))) {
             if (md5($request->getPost('susvPassword')) == md5($request->getPost('rePassword'))) {
                 $user = $this->em->find('Application\\Entity\\WebsiteTbSecurityUser', $request->getPost('susiId'));
                 $susvPassword = Encrypt::encrypt(trim($request->getPost('susvPassword')), $user->getSusvLoginname());
                 $user->setSusvPassword($susvPassword);
                 $this->em->persist($user);
                 $this->em->flush();
             }
         }
         $userDescription = $this->em->getRepository('Application\\Entity\\WebsiteTbSecurityUserDescription')->findOneBySusi($request->getPost('susiId'));
         $userDescription->setSudvName(trim($request->getPost('sudvName')))->setSudvLastname(trim($request->getPost('sudvLastname')));
         $this->em->persist($userDescription);
         $this->em->flush();
         return $this->redirect()->toRoute('user-list');
     } else {
         $id = $this->params()->fromRoute('id', false);
         $notEmpty_obj = new NotEmpty();
         if (!$notEmpty_obj->isValid($id)) {
             $id = false;
         }
         if (!is_numeric($id) || $id <= 0) {
             $id = false;
         }
         if ($id === false) {
             return $this->redirect()->toRoute('dashboard');
         }
         $user = $this->em->getRepository('Application\\Entity\\WebsiteTbSecurityUserDescription')->findOneBySusi($id);
         $array = array('user' => $user);
         return new ViewModel($array);
     }
 }
Ejemplo n.º 3
0
 public function editAction()
 {
     $request = $this->getRequest();
     if ($request->isPost()) {
         $email = $request->getPost('user-email', false);
         $empty_obj = new NotEmpty();
         if (!$empty_obj->isValid($email) || !$email) {
             throw new \RuntimeException("Not a valid email address given");
         }
         $email_obj = $this->em->getRepository('Application\\Entity\\ClientUser')->findOneByCluvEmail($email);
         if ($empty_obj->isValid($email_obj) && $email_obj->getCluiId() != $request->getPost('user-id', 0)) {
             throw new \RuntimeException("The email given is already in use. Try with another one.");
         }
         $client_obj = $this->em->find('Application\\Entity\\Client', $request->getPost('client-id', 0));
         $client_obj->setClivName(trim($request->getPost('client-name')));
         $this->em->persist($client_obj);
         $user_obj = $this->em->find('Application\\Entity\\ClientUser', $request->getPost('user-id', 0));
         $user_obj->setClii($client_obj)->setCluvUser(md5(trim($request->getPost('user-email'))))->setCluvEmail(trim($request->getPost('user-email')));
         $storedPass = $user_obj->getCluvPassword();
         $newPass = Encrypt::encrypt(trim($request->getPost('user-password')), trim($request->getPost('user-email')));
         if ($storedPass !== $newPass) {
             $user_obj->setCluvPassword($newPass);
         }
         $this->em->persist($user_obj);
         $this->em->flush();
     }
     return $this->redirect()->toRoute('view-client', array('id' => $request->getPost('client-id', 0)));
 }