public function indexAction()
 {
     $this->layout('layout/layoutLogin');
     $request = $this->getRequest();
     $form = new LoginForm();
     if ($request->isPost()) {
         $form->setData($request->getPost()->toArray());
         if ($form->isValid()) {
             $post = $request->getPost()->toArray();
             #Criando storage para gravar sessão de authenticacação
             $sessionStorage = new SessionStorage('FuncSessao');
             $auth = new AuthenticationService();
             $auth->setStorage($sessionStorage);
             #Definindo session storage pra auth
             $authAdapter = $this->getServiceLocator()->get('Application\\Auth\\Adapter');
             $authAdapter->setUsername($post['usuarioFunc']);
             $authAdapter->setPassword($post['senhaFunc']);
             $result = $auth->authenticate($authAdapter);
             if ($result->isValid()) {
                 $sessionStorage->write($auth->getIdentity()['funcionarioUser']);
                 return $this->redirect()->toUrl('/application/index/index');
             } else {
                 var_dump("ERROR");
                 $error = true;
             }
         }
     }
     $view = new ViewModel();
     $view->setVariable('form', $form);
     return $view;
 }
示例#2
0
 public function logInAction()
 {
     $request = $this->getRequest();
     $form = new LoginForm();
     $loginFailed = false;
     if ($request->isPost()) {
         // Check if the form and provided values are valid, and redirect if so
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $data = $form->getData();
             /** @var Adapter $auth */
             $auth = $this->serviceLocator->get('auth');
             $authAdapter = $auth->getAdapter();
             $authAdapter->setIdentity($data['username']);
             $authAdapter->setCredential($data['password']);
             $result = $auth->authenticate();
             if ($result->isValid()) {
                 return $this->redirect()->toRoute('application/game');
             } else {
                 $loginFailed = true;
             }
         }
     }
     return new ViewModel(['form' => $form, 'loginFailed' => $loginFailed]);
 }
 public function loginAction()
 {
     $user = $this->identity();
     $form = new LoginForm();
     $form->get('submit')->setValue('Login');
     $messages = null;
     $request = $this->getRequest();
     if ($request->isPost()) {
         $registerFormFilters = new Register();
         $form->setInputFilter($registerFormFilters->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $data = $form->getData();
             $sm = $this->getServiceLocator();
             $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
             $config = $this->getServiceLocator()->get('Config');
             $staticSalt = $config['static_salt'];
             $authAdapter = new AuthAdapter($dbAdapter, 'registration', 'usr_name', 'usr_password', "MD5(CONCAT('{$staticSalt}', ?, usr_password_salt)) AND usr_active = 1");
             $authAdapter->setIdentity($data['usr_name'])->setCredential($data['usr_password']);
             $auth = new AuthenticationService();
             // or prepare in the globa.config.php and get it from there. Better to be in a module, so we can replace in another module.
             // $auth = $this->getServiceLocator()->get('Zend\Authentication\AuthenticationService');
             // $sm->setService('Zend\Authentication\AuthenticationService', $auth); // You can set the service here but will be loaded only if this action called.
             $result = $auth->authenticate($authAdapter);
             switch ($result->getCode()) {
                 case Result::FAILURE_IDENTITY_NOT_FOUND:
                     // do stuff for nonexistent identity
                     break;
                 case Result::FAILURE_CREDENTIAL_INVALID:
                     // do stuff for invalid credential
                     break;
                 case Result::SUCCESS:
                     $storage = $auth->getStorage();
                     $storage->write($authAdapter->getResultRowObject(null, 'usr_password'));
                     $time = 1209600;
                     // 14 days 1209600/3600 = 336 hours => 336/24 = 14 days
                     //						if ($data['rememberme']) $storage->getSession()->getManager()->rememberMe($time); // no way to get the session
                     if ($data['rememberme']) {
                         $sessionManager = new \Zend\Session\SessionManager();
                         $sessionManager->rememberMe($time);
                     }
                     break;
                 default:
                     // do stuff for other failure
                     break;
             }
             foreach ($result->getMessages() as $message) {
                 $messages .= "{$message}\n";
             }
         }
     }
     return new ViewModel(array('form' => $form, 'messages' => $messages));
 }
 public function loginAction()
 {
     $loginForm = new LoginForm();
     $request = $this->getServiceLocator()->get('request');
     $data = $request->getPost()->toArray();
     $loginForm->setData($data);
     if ($request->isPost()) {
         if ($loginForm->isValid()) {
             $this->validateForm($data, $loginForm);
         }
     }
     return new ViewModel(array('form' => $loginForm));
 }
示例#5
0
 public function indexAction()
 {
     $form = new LoginForm();
     $request = $this->getServiceLocator()->get('request');
     if ($request->isPost()) {
         $data = $request->getPost()->toArray();
         $form->setData($data);
         if ($form->isValid()) {
             $userTable = $this->getLoginTable()->getLoginUser();
         }
     }
     return array('form' => $form);
 }
示例#6
0
 /**
  * Main function for login
  * @return TRUE
  * */
 public function loginAction()
 {
     // login form object
     $loginForm = new LoginForm();
     $request = $this->getServiceLocator()->get('request');
     $data = $request->getPost()->toArray();
     //set the post data to form
     $loginForm->setData($data);
     if ($request->isPost()) {
         if ($loginForm->isValid()) {
             $this->validateForm($data, $loginForm);
         }
     }
     return $this->renderView(array('form' => $loginForm));
 }
示例#7
0
 public function indexAction()
 {
     $request = $this->getRequest();
     $view = new ViewModel();
     $loginForm = new LoginForm('loginForm');
     $loginForm->setInputFilter(new LoginFilter());
     if ($request->isPost()) {
         $data = $request->getPost();
         $loginForm->setData($data);
         if ($loginForm->isValid()) {
             $data = $loginForm->getData();
             $userPassword = new UserPassword();
             $encyptPass = $userPassword->create($data['password']);
             $this->getAuthService()->getAdapter()->setIdentity($data['email'])->setCredential($encyptPass);
             $result = $this->getAuthService()->authenticate();
             if ($result->isValid()) {
                 $session = new Container('User');
                 $session->offsetSet('email', $data['email']);
                 $this->flashMessenger()->addMessage(array('success' => 'Login Success.'));
                 // Redirect to page after successful login
             } else {
                 $this->flashMessenger()->addMessage(array('error' => 'invalid credentials.'));
                 // Redirect to page after login failure
             }
             return $this->redirect()->tourl('/application/login');
             // Logic for login authentication
         } else {
             $errors = $loginForm->getMessages();
             //prx($errors);
         }
     }
     $view->setVariable('loginForm', $loginForm);
     return $view;
 }
示例#8
0
 public function loginAction()
 {
     if (!$this->logged->boolLogged) {
         $form = new LoginForm();
         $request = $this->getRequest();
         if ($request->isPost()) {
             $login = new User();
             $login->setInputs(['nick', 'heslo']);
             $form->setInputFilter($login->getInputFilter());
             $form->setData($request->getPost());
             if ($form->isValid()) {
                 $table = $this->getUserTable();
                 $data = array('nick' => $form->getData()['nick'], 'heslo' => $form->getData()['heslo']);
                 $login->exchangeArray($data);
                 if ($user = $table->login($login)) {
                     foreach ($user as $u) {
                         $this->logged->nick = $u->nick;
                         $this->logged->admin = $u->admin;
                         $this->logged->boolLogged = true;
                         return $this->redirect()->toRoute('application/default', array('controller' => 'profil'));
                     }
                 } else {
                     $error = $this->msg->get('login.error.invalidCredentials');
                 }
             } else {
                 $error = $this->msg->get('form.error.invalidData');
             }
         }
         return array('form' => $form, 'error' => isset($error) ? $error : null, 'menu' => new Menu($this->url()->fromRoute("application"), array("login", "registrace", "obnovit" => "zapomenuté heslo"), "login"));
     } else {
         return $this->redirect()->toRoute('application/default', array('controller' => 'profil'));
     }
 }
 public function loginAction()
 {
     $user = ApplicationManager::getInstance($this->getServiceLocator())->getCurrentUser();
     if ($user) {
         return $this->redirect()->toRoute('home');
     }
     $request = $this->getRequest();
     $form = new LoginForm();
     if ($request->isPost()) {
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $data = $form->getData();
             $identity = $data['email'];
             $password = $data['password'];
             $result = AuthenticationManager::getInstance($this->getServiceLocator())->authenticate($identity, $password);
             if (in_array($result->getCode(), array(Result::FAILURE_IDENTITY_NOT_FOUND, Result::FAILURE_CREDENTIAL_INVALID))) {
                 $form->setMessages(array('email' => array('Нeправильный Email или пароль')));
             }
             if ($result->isValid()) {
                 return $this->redirect()->toRoute('dashboard');
             }
         } else {
             $form->setMessages(array('email' => array('Нeправильный Email или пароль')));
         }
     }
     $viewModel = new ViewModel(array('form' => $form));
     $viewModel->setTemplate('layout/login-layout');
     $viewModel->setTerminal(true);
     return $viewModel;
 }
 public function loginAction()
 {
     $form = new LoginForm();
     $form->get('submit')->setValue('Login');
     /** @var \Zend\Http\PhpEnvironment\Request $request */
     $request = $this->getRequest();
     $referer = $request->getHeader('referer');
     if ($referer === false) {
         return $this->redirect()->toRoute('home');
     } else {
         $referer_path = $referer->uri()->getPath();
     }
     $current_path = $request->getUri()->getPath();
     $_SESSION['referer_path'] = $referer_path;
     if ($request->isPost()) {
         $validate = new LoginFilter();
         $form->setInputFilter($validate->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $validate->exchangeArray($form->getData());
             $ident = $validate->getInputFilter()->getValue('name');
             $password = $validate->getInputFilter()->getValue('password');
             $auth = new AuthAccess();
             $authenticated = $auth->isAuthenticated($ident, $password);
             if ($authenticated) {
                 $redirect_path = $_SESSION['referer_path'];
                 if ($redirect_path == '/') {
                     $this->redirect()->toRoute('home');
                 } elseif ($redirect_path == $current_path) {
                     $this->redirect()->toRoute('home');
                 }
                 $redirect_route = str_replace('/', '', $redirect_path);
                 $this->redirect()->toRoute($redirect_route);
             } else {
                 $this->redirect()->toRoute('login');
             }
         }
     }
     return array('form' => $form);
 }
 /**
  * Retorna o formulario de login
  *
  * @return LoginForm
  */
 private function getFormularioLogin()
 {
     if (!$this->loginForm) {
         $options = $this->getServiceLocator()->get('zfcuser_module_options');
         $form = new LoginForm('loginForm', $options);
         $form->setInputFilter(new LoginFilter($options));
         $this->setLoginForm($form);
     }
     return $this->loginForm;
 }
示例#12
0
 /**
  * Function to process login 
  * @author Aditya
  */
 public function userloginAction()
 {
     /** New Code * */
     $messages = array();
     $em = $this->getEntityManager();
     $formData = $this->getRequest()->getPost()->toArray();
     $viewModel = new ViewModel();
     $viewModel->setTerminal(true);
     $form = new Forms\LoginForm();
     $request = $this->getRequest();
     $referrerUrl = "";
     if ($request->isXmlHttpRequest()) {
         $formValidator = new Forms\Validator\LoginFormValidator();
         $form->setInputFilter($formValidator->getInputFilter());
         $form->setData($formData);
         $data = array('email' => $formData['email'], 'password' => $formData['password']);
         if ($form->isValid()) {
             $results = $em->getRepository('Admin\\Entity\\Users')->verifyUser($data);
             if (!empty($results)) {
                 if ($results[0]['isForgotStatus'] != 2) {
                     $name = $results[0]['firstName'] . ' ' . $results[0]['lastName'];
                     $commobj = $this->Common();
                     if (trim($name) == "") {
                         $name = $commobj->trimString($formData['email'], 12);
                     }
                     $user_session = new Container('user');
                     $user_session->userId = $results[0]['id'];
                     $user_session->userName = $name;
                     if ($results[0]['isForgotStatus'] == 1) {
                         $tmpObj = $em->getRepository('\\Admin\\Entity\\Users')->find($results[0]['id']);
                         $tmpObj->setIsForgotStatus(2);
                         $em->persist($tmpObj);
                         $em->flush();
                         $flashMessenger = $this->flashMessenger();
                         $flashMessenger->setNamespace('success');
                         $msg = "Old Password is the OTP you received in your Email";
                         $status = 1;
                     } else {
                         $msg = "You have been logged in successfully.";
                         $status = 2;
                         $referrerUrl = $this->getRequest()->getHeader('Referer')->getUri();
                     }
                 } else {
                     $msg = "Your OTP has expired. Kindly regenerate your password using Forgot Password Link";
                     $status = 0;
                 }
             } else {
                 $msg = 'Sorry! You have entered an incorrect email or password. Please enter correct login details to proceed';
                 $status = 0;
             }
         } else {
             $msg = 'Kindly recheck your details. It seems to be incorrect';
             $status = 0;
         }
     }
     $tmp_arr = json_encode(array('status' => $status, 'msg' => $msg, 'reffererUrl' => $referrerUrl));
     echo $tmp_arr;
     die;
 }
 public function signinAction()
 {
     if (!$this->getRequest()->isPost()) {
         $this->redirect()->toUrl('/accounts/login');
     }
     $post = $this->request->getPost();
     // Validation form ----
     $formLogin = new LoginForm();
     $formLogin->setData($post);
     if (!$formLogin->isValid()) {
         $model = new ViewModel(array('formLogin' => $formLogin, 'message' => '111', 'error' => true));
         $model->setTemplate('accounts/login');
         return $model;
     }
     // Validation auth
     $profile = $this->getUsersTable()->getOneBy(array('profile_name' => $post['profile_name'], 'password' => md5($post['password'])));
     if (!$profile) {
         $view = new ViewModel(array('formLogin' => $formLogin, 'message' => 'Incorrect Profile name or Password.', 'error' => true));
         $view->setTemplate('accounts/login');
         return $view;
     }
     $_SESSION['id'] = $profile['id'];
     $_SESSION['profile_name'] = $profile['profile_name'];
     $_SESSION['email'] = $profile['email'];
     $_SESSION['password'] = $profile['password'];
     $this->redirect()->toUrl('/' . $profile['profile_name']);
 }
示例#14
0
 /**
  * Injecting Zend Translate and Doctrine ORM into Forms, setting filters and hydrators
  */
 public function getFormElementConfig()
 {
     return array('factories' => array('contactForm' => function ($sm) {
         $form = new Form\ContactForm('contactform', $sm->getServiceLocator()->get('translator'), $sm->getServiceLocator()->get('Doctrine\\ORM\\EntityManager'), array());
         $form->setInputFilter(new Form\ContactFilter());
         $form->setHydrator(new \Zend\Stdlib\Hydrator\ObjectProperty());
         return $form;
     }, 'registerForm' => function ($sm) {
         $form = new Form\RegisterForm('registerform', $sm->getServiceLocator()->get('translator'), $sm->getServiceLocator()->get('Doctrine\\ORM\\EntityManager'), array());
         //$form->setInputFilter(new Form\RegisterFilter); //set in Controller as using Doctrine2
         $form->setHydrator(new \Zend\Stdlib\Hydrator\ObjectProperty());
         return $form;
     }, 'forgotpwdForm' => function ($sm) {
         $form = new Form\ForgotpwdForm('forgotpwdform', $sm->getServiceLocator()->get('translator'), $sm->getServiceLocator()->get('Doctrine\\ORM\\EntityManager'), array());
         //$form->setInputFilter(new Form\ForgotpwdFilter); //set in Controller as using Doctrine2
         $form->setHydrator(new \Zend\Stdlib\Hydrator\ObjectProperty());
         return $form;
     }, 'resetpwdForm' => function ($sm) {
         $form = new Form\ResetpwdForm('resetpwdform', $sm->getServiceLocator()->get('translator'), $sm->getServiceLocator()->get('Doctrine\\ORM\\EntityManager'), array());
         //$form->setInputFilter(new Form\ResetpwdFilter); //set in Controller as using Doctrine2
         $form->setHydrator(new \Zend\Stdlib\Hydrator\ObjectProperty());
         return $form;
     }, 'loginForm' => function ($sm) {
         $form = new Form\LoginForm('loginform', $sm->getServiceLocator()->get('translator'), $sm->getServiceLocator()->get('Doctrine\\ORM\\EntityManager'), array());
         $form->setInputFilter(new Form\LoginFilter());
         $form->setHydrator(new \Zend\Stdlib\Hydrator\ObjectProperty());
         return $form;
     }, 'profileForm' => function ($sm) {
         $form = new Form\ProfileForm('profileform', $sm->getServiceLocator()->get('translator'), $sm->getServiceLocator()->get('Doctrine\\ORM\\EntityManager'), array());
         //$form->setInputFilter(new Form\ProfileFilter); //set in Controller as using Doctrine2
         $form->setHydrator(new \Zend\Stdlib\Hydrator\ObjectProperty());
         return $form;
     }, 'newsForm' => function ($sm) {
         $form = new Form\NewsForm('newsform', $sm->getServiceLocator()->get('translator'), $sm->getServiceLocator()->get('Doctrine\\ORM\\EntityManager'), array());
         //$form->setInputFilter(new Form\NewsFilter); //set in Controller as using Doctrine2
         $form->setHydrator(new \Zend\Stdlib\Hydrator\ObjectProperty());
         return $form;
     }));
 }
示例#15
0
 public function indexAction()
 {
     $api = new Api();
     $auth = new FrontEndAuth();
     $session = new Container('frontend');
     $loginError = "";
     $seturl = $this->getRequest()->getQuery('last_url');
     //$redirectUrl = 'http://blog.ovessence.in/';
     if ($auth->hasIdentity()) {
         if ($session->status_id != 3) {
             //$redirectUrl = array('controller' => 'practitioner', 'action' => 'list'):array('controller' => 'practitioner', 'action' => 'dashboard');
             return $session->user_type_id == 4 ? $this->redirect()->toRoute('consumer', array('action' => 'dashboard')) : $this->redirect()->toRoute('practitioner', array('action' => 'dashboard'));
         } else {
             $loginError = "Sorry your are suspended to access this site ..!! ";
             $auth->logout($redirectUrl);
         }
     }
     $form = new LoginForm();
     $register_form = new RegisterForm();
     //$forWishlist = new Container('last_url');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $login = new Login();
         $form->setInputFilter($login->getInputFilter());
         $data = $request->getPost()->toArray();
         $form->setData($data);
         if ($form->isValid()) {
             //unset($data['rememberme'], $data['submit']);
             $bookingData = new Container('bookingData');
             $api_url = $this->getServiceLocator()->get('Config')['api_url']['value'];
             $url = $api_url . "/api/useractivity/";
             //$data = array("username" => "sazid1s", "password" => "123456", "op" => "login");
             $data['op'] = 'login';
             $res = $api->curl($url, $data, "POST");
             //var_dump($res); die;
             if ($res->getStatusCode() == 200) {
                 $content = json_decode($res->getBody(), true);
                 if ($content['status_id'] != 3) {
                     //Get verifiy status
                     $url = $api_url . "/api/userverification/?user_id=" . $content['id'];
                     $res = $api->curl($url, array(), "GET");
                     $result = json_decode($res->getBody(), true);
                     $emailStatus = 0;
                     $smsStatus = 0;
                     if (count($result) > 0) {
                         // retrieving verification code
                         foreach ($result as $userid) {
                             // email validation where 1:- email
                             if ($userid['verification_type_id'] == 1) {
                                 $emailStatus = $userid['verification_status'];
                             }
                             // sms validation where 2:- for sms
                             if ($userid['verification_type_id'] == 2) {
                                 $smsStatus = $userid['verification_status'];
                             }
                         }
                     }
                     //End:- Get verifiy status
                     $session->userid = $content['id'];
                     $session->first_name = $content['first_name'];
                     $session->last_name = $content['last_name'];
                     $session->email = $content['email'];
                     $session->user_name = $content['user_name'];
                     $session->user_type_id = $content['user_type_id'];
                     $session->user_data = $content;
                     $session->status_id = $content['status_id'];
                     $session->last_login = $content['last_login_prev'];
                     $session->email_verification_status = $emailStatus;
                     $session->sms_verification_status = $smsStatus;
                     // SET Cookies
                     $time = $data['rememberme'] == 'yes' ? time() + 365 * 60 * 60 * 24 : time() - 4;
                     $cookie = new SetCookie('username', $content['user_name'], $time);
                     // now + 1 year
                     $cookie1 = new SetCookie('password', $data['Pass'], $time);
                     // now + 1 year
                     $cookie2 = new SetCookie('rememberme', $data['rememberme'], $time);
                     // now + 1 year
                     $response = $this->getResponse()->getHeaders();
                     $response->addHeader($cookie);
                     $response->addHeader($cookie1);
                     $response->addHeader($cookie2);
                     // End set cookies
                     if ($data['rememberme'] == 'yes') {
                         setcookie("user_name", $content['user_name'], time() + 60 * 60 * 1);
                         setcookie("password", $data['Pass'], time() + 60 * 60 * 1);
                         /* expire in 1 hour */
                     }
                     $auth->wordpress_login($session->user_name);
                     $redirectUrl = $session->user_type_id == 4 ? array('controller' => 'consumer', 'action' => 'dashboard') : array('controller' => 'practitioner', 'action' => 'dashboard');
                     if (isset($bookingData->bookingData)) {
                         return $this->redirect()->toRoute('booking', array('action' => 'schedule', 'id' => $bookingData->sp));
                     } else {
                         if ($this->getRequest()->getQuery('lasturl') != '') {
                             return $this->redirect()->toUrl($this->getRequest()->getQuery('lasturl'));
                         } else {
                             return $session->user_type_id == 4 ? $this->redirect()->toRoute('consumer', array('action' => 'dashboard')) : $this->redirect()->toRoute('practitioner', array('action' => 'dashboard'));
                         }
                     }
                 }
                 //Status check
                 $loginError = "Sorry your are suspended to access this site ..!! ";
                 //return $this->redirect()->toUrl($redirectUrl);
             } else {
                 $loginError = "Username or Password is incorrect";
             }
         }
     } else {
         $username = $this->getRequest()->getHeaders()->get('Cookie')->username ? $this->getRequest()->getHeaders()->get('Cookie')->username : '';
         $password = $this->getRequest()->getHeaders()->get('Cookie')->password ? $this->getRequest()->getHeaders()->get('Cookie')->password : '';
         $rememberme = $this->getRequest()->getHeaders()->get('Cookie')->password ? $this->getRequest()->getHeaders()->get('Cookie')->rememberme : '';
         $form->get('Pass')->setValue($password);
         $form->get('user_name')->setValue($username);
         $form->get('rememberme')->setValue($rememberme);
     }
     return new ViewModel(array('form' => $form, 'register_form' => $register_form, 'loginError' => $loginError, 'setUrl' => $seturl));
 }