public function insert(UserModel $user) { $data = array('user_id' => $user->getUserId(), 'email' => $user->getEmail(), 'display_name' => $user->getDisplayName(), 'password' => $user->getPassword(), 'salt' => $user->getSalt(), 'register_time' => new Expr('NOW()'), 'register_ip' => new Expr("INET_ATON('{$_SERVER['REMOTE_ADDR']}')")); $db = $this->getWriteAdapter(); $db->insert($this->getTableName(), $data); $userId = $db->lastInsertId(); $user->setUserId($userId); return $user; }
public function loginAction() { // $user = $this->identity(); $user = new User($this->getServiceLocator()); $form = new AdminForm(); $form->get('submit')->setValue('Login'); $messages = null; $request = $this->getRequest(); if ($request->isPost()) { $userdetail = $user->getUserId($request); if ($userdetail) { $messages = "Successful login"; $container = new Container('adminloginuser'); $container->userdetail = $userdetail; $container->userid = $userdetail['id']; return $this->redirect()->toRoute('admin/default', array('controller' => 'index', 'action' => 'index')); } else { $messages = "Error login"; return new ViewModel(array('form' => $form, 'messages' => $messages)); } } else { return new ViewModel(array('form' => $form)); } }