public function postAction() { // Params $params = $this->_helper->param(); $response = $this->_helper->response(); $valid = true; // Validatation // Exist user $count = Doctrine_Core::getTable('Model_Entity_User')->findByemail($params['email'])->count(); if ($count > 0) { $response->addNotification(Kebab_Notification::ERR, 'There is a user with this email'); $valid = false; } // Invalid email address if (!Kebab_Validation_Email::isValid($params['email'])) { $response->addNotification(Kebab_Notification::ERR, 'Invalid email address'); $valid = false; } // Check Fullname only Alpha chracter enable if (!Kebab_Validation_FullName::isValid($params['fullName'])) { $response->addNotification(Kebab_Notification::ERR, 'Only alpha character enable.'); $valid = false; } // Model if ($valid) { $user = Kebab_Model_User::invite($params['fullName'], $params['email']); } // Response if ($valid && is_object($user)) { $this->sendInviteMail($user, $params['message']); $response->setSuccess(true); } $response->getResponse(); }
public static function signIn($userName, $password, $rememberMe = false, $md5 = true) { $retVal = false; // set ZendX_Doctrine_Auth_Adapter $auth = Zend_Auth::getInstance(); $authAdapter = new ZendX_Doctrine_Auth_Adapter(Doctrine::getConnectionByTableName('Model_Entity_User')); $password = $md5 ? md5($password) : $password; $authAdapter->setTableName('Model_Entity_User u')->setIdentityColumn('userName')->setCredentialColumn('password')->setCredentialTreatment('? AND active = 1')->setIdentity($userName)->setCredential($password); // set Zend_Auth $result = $auth->authenticate($authAdapter); // Check Auth Validation if ($result->isValid()) { // Remove some fields which are secure! $omitColumns = array('password', 'activationKey', 'created_at', 'updated_at', 'deleted_at', 'created_by', 'updated_by'); $identity = $authAdapter->getResultRowObject(null, $omitColumns); $identity->roles = Kebab_Model_User::getUserRoles($identity->id); $identity->acl = new Kebab_Access_Acl(); $identity->stories = Kebab_Model_Story::getUserStoriesName($identity->roles); $auth->getStorage()->write($identity); if ($rememberMe) { Zend_Session::rememberMe(604800); } $retVal = true; } return $retVal; }
public function indexAction() { // Mapping $mapping = array('id' => 'user.id', 'fullName' => 'user.fullName', 'userName' => 'user.userName', 'email' => 'user.email', 'language' => 'user.language', 'status' => 'user.status', 'active' => 'user.active'); $searchUser = $this->_helper->search('Model_Entity_User'); $order = $this->_helper->sort($mapping); $query = Kebab_Model_User::getAll($searchUser, $order); $pager = $this->_helper->pagination($query); $user = $pager->execute(); // Response $responseData = is_object($user) ? $user->toArray() : array(); $this->_helper->response(true)->addData($responseData)->addTotal($pager->getNumResults())->getResponse(); }
/** * User can invited or sign-up * * @return void */ public function postAction() { // Getting parameters $params = $this->_helper->param(); $response = $this->_helper->response(true); // Check username dublicate $user = Doctrine_Core::getTable('Model_Entity_User')->findOneByuserName(array($params['userName'])); if (is_object($user)) { $response->setSuccess(false)->addNotification(Kebab_Notification::ERR, 'This username is already at system.')->getResponse(); } $user = Kebab_Model_User::activate($params['userName'], $params['password'], $params['fullName'], $params['activationKey']); Kebab_Authentication::signIn($user->userName, $params['password']); $response->getResponse(); }
public function postAction() { $params = $this->_helper->param(); $response = $this->_helper->response(); // Check email $isValidEmail = Kebab_Validation_Email::isValid($params['email']); $isUnusedEmail = is_object(Doctrine_Core::getTable('Model_Entity_User')->findOneByemail($params['email'])); if (!$isValidEmail) { throw new Kebab_Exception("Invalid email wanna to signup."); } if (!$isUnusedEmail) { $user = Kebab_Model_User::signUp($params['fullName'], $params['email']); $this->sendSignUpMail($user); $response->setSuccess(true)->getResponse(); } else { $response->addError('email', 'An other user uses this email'); } $response->getResponse(); }