public function createAction()
 {
     if ($this->request->isPost() == true) {
         $username = $this->request->getPost("username");
         $password = $this->security->hash($this->request->getPost("password"));
         $check_user = Users::findFirstByName($username);
         if ($check_user->password != "") {
             // username already taken
             $this->session->set("adduser", "username is already registered");
             $this->response->redirect("adduser");
         } else {
             if (!empty($username) && !empty($password)) {
                 // username unique
                 $user = new Users();
                 $user->name = $username;
                 $user->password = $password;
                 if (!$user->save()) {
                     $this->session->set("adduser", "");
                     $this->response->redirect('adduser');
                 } else {
                     $this->response->redirect("");
                 }
             }
         }
     }
 }
 public function indexAction()
 {
     // get username and password in config
     $authConfig = $this->di->get('env')->auth_id;
     if ($this->request->isPost() == true) {
         // retrieve user information from POST request
         $username = $this->request->getPost("usernamecron");
         // username with magento sign in
         $password = $this->request->getPost("passwordcron");
         // password with magento sign in
     }
     if (isset($username) && !empty($username)) {
         $user = Users::findFirstByName($username);
         if (!empty($user)) {
             if ($this->security->checkHash($password, $user->password)) {
                 $this->session->set('auth', array('username' => $username, 'imageurl' => ''));
                 $this->view->setVar("login_notification", "alright");
                 header('Location: ' . $this->url->getBaseUri());
                 die;
             } else {
                 $this->view->setVar("login_notification", "Invalid username or password.");
             }
         } else {
             $this->view->setVar("login_notification", "Invalid username or password.");
         }
     }
 }