public function action_perform_login() { if (\CMF\Auth::authenticate(\Input::post('username'), \Input::post('password'))) { \Response::redirect('/' . ltrim(\Input::post('next', 'admin/' . \Config::get('cmf.admin.default_section')), '/'), 'location'); } else { \Session::set_flash('main_alert', array('attributes' => array('class' => 'alert-danger'), 'msg' => \Lang::get('admin.errors.account.invalid'))); return \View::forge('admin/auth/login.twig', array('next' => \Input::get('next'))); } }
/** * Creates a new session and API key * @return array */ public function action_add() { $user_type = \Input::param('user_type') ?: 'Admin\\Model_User'; $scope = \Input::param('scope') ?: 'api'; if (\CMF\Auth::authenticate(\Input::post('username'), \Input::post('password'), $user_type)) { // Purge old keys $this->removeOldKeys(); // Find the logged in user and get an API key for it $user = \CMF\Auth::current_user(); $key = $this->getKey($user, $user_type, $scope); $user_data = $user->toArray(); unset($user_data['encrypted_password']); return array('user' => $user_data, 'api_key' => $key->toArray()); } throw new \HttpException('Invalid Login', \HttpException::UNAUTHORIZED); }