public function __construct() { parent::__construct(); // Load profiler if (Kohana::config('config.enable_profiler')) { $this->profiler = new Profiler(); } $this->auth = Auth::instance(); $this->db = Database::instance(); // Are we logged in? if not, do we have an auto-login cookie? if (!$this->auth->logged_in()) { // Try to login with 'remember me' token if (!$this->auth->auto_login()) { // Login user in via HTTP AUTH $this->auth->http_auth_login(); } } // Get session information $this->user = Auth::instance()->get_user(); // Check private deployment access $controller_whitelist = array('login', 'riverid', 'api', 'frontlinesms', 'smssync', 'nexmo'); if (Kohana::config('settings.private_deployment')) { if (!$this->auth->logged_in('login') and !in_array(Router::$controller, $controller_whitelist)) { // Redirect to login form url::redirect('login'); } } // Set default content-type header header('Content-type: text/html; charset=UTF-8'); }
public function action_signout() { #Sign out the user Auth::instance()->logout(); #redirect to the user account and then the signin page if logout worked as expected Request::instance()->redirect('/admin/site/index'); }
public function setTrackerListCount() { $auth = Auth::instance(); $loggedInEmpNumber = $auth->getEmployeeNumber(); $searchParameter = array('limit' => null, 'employeeId' => $loggedInEmpNumber); $this->trackListCount = $this->getPerformanceTrackerService()->getPerformanceTrackListCountByEmployee($searchParameter); }
public function delete($id = NULL) { if (Auth::instance()->get_user()->id == $this->id || Auth::instance()->get_user()->id == $id) { return; } parent::delete($id); }
public function __construct() { if (!Auth::instance()->logged_in('admin')) { Event::run('system.404'); } parent::__construct(); }
public function render() { $view = View::factory('feed/' . $this->type . '_' . $this->action)->bind('lecture', $lecture)->bind('user', $user)->bind('span', $span)->bind('role', $role)->bind('feed_id', $feed_id)->bind('comments', $comments)->bind('url', $url); if ($this->action == 'add') { $lecture = ORM::factory('lecture', $this->respective_id); if ($this->check_deleted($lecture)) { return View::factory('feed/unavaliable')->render(); } } else { if ($this->action == 'canceled') { $lecture = Model_Lecture::get_lecture_from_event($this->respective_id); $event = ORM::factory('event', $this->respective_id); if ($this->check_deleted($lecture)) { return View::factory('feed/unavaliable')->render(); } $view->bind('event', $event); } } $user = ORM::factory('user', $this->actor_id); $span = Date::fuzzy_span($this->time); $feed_id = $this->id; $curr_user = Auth::instance()->get_user(); $role = $curr_user->role()->name; $comment = ORM::factory('feedcomment'); $comment->where('feed_id', '=', $feed_id)->order_by('date', 'DESC'); $comments = $comment->find_all(); $url = Url::site('profile/view/id/'); return $view->render(); }
public function action_index() { if (!Auth::instance()->logged_in() && isset($_POST['login'])) { $user = ORM::factory('User'); $status = Auth::instance()->login($_POST['username'], $_POST['password'], true); if ($status) { HTTP::redirect('/'); } } if (Auth::instance()->logged_in() && isset($_POST['logout'])) { Auth::instance()->logout(); } if (!Auth::instance()->logged_in()) { Guestid::factory()->get_id(); } $templateData['title'] = 'Главная.'; $templateData['description'] = ''; $template = View::factory('template')->set('templateData', $templateData); $content = View::factory("catalog"); $content->get = $_GET; $content->shopArr = Model::factory('Shop')->getShop(); $root_page = "index"; $template->root_page = $root_page; $template->content = $content; $this->response->body($template); }
public static function getBestUser() { if (self::$bestUserRun) { return self::$bestUser; } $user = null; $segments = URL::getItems(); foreach ($segments as $uname) { if (!in_array($uname, self::$skipNames)) { if (is_numeric($uname)) { $user = ORM::factory("user", $uname); } else { $user = ORM::factory("user")->where('vanity_url', '=', $uname)->find(); } if ($user && $user->loaded()) { break; } } } if (empty($user) || !$user->loaded()) { $user = Auth::instance()->get_user(); } if (empty($user) || !$user->loaded()) { $user = new stdClass(); $user->loaded = function () { return false; }; } self::$bestUserRun = true; self::$bestUser = $user; return $user; }
public function action_index() { $message = false; $user = false; if (Arr::get($_POST, 'hidden') == 'form_sent') { if (Auth::instance()->login(Arr::get($_POST, 'username'), Arr::get($_POST, 'password'), Arr::get($_POST, 'remember'))) { $user = Auth::instance()->get_user(); Session::instance()->set('username', $user->name . ' ' . $user->surname)->set('language', $user->language)->set('listsize', $user->listsize); } } if (Auth::instance()->logged_in()) { $user = Auth::instance()->get_user(); Session::instance()->set('username', $user->name . ' ' . $user->surname)->set('language', $user->language)->set('listsize', $user->listsize); try { $server_config = $user->object->as_array(); $fb_config = array('type' => 'pdo', 'connection' => array('dsn' => 'firebird:dbname=' . $server_config['config_server'] . ':' . $server_config['config_bdfile'], 'username' => $server_config['config_bduser'], 'password' => $server_config['config_bdpass'])); Session::instance()->set('fb_config', $fb_config); $fb = Database::instance('fb', $fb_config); //$fb->connect(); $this->request->redirect('/admin/'); } catch (Database_Exception $e) { $message = __('error.connection_db'); Auth::instance()->logout(); } } $this->request->response = View::factory('login', array('message' => $message)); }
public function before() { parent::before(); // The user is already logged in if (Auth::instance()->logged_in()) { Request::instance()->redirect(''); } // Load the configuration for this provider $config = Kohana::config('oauth.'.$this->provider); // Create a consumer from the config $this->consumer = OAuth_Consumer::factory($config); // Load the provider $this->provider = OAuth_Provider::factory($this->provider); if ($token = Cookie::get($this->cookie)) { // Get the token from storage $this->token = unserialize($token); } }
/** * View the marksheet of a student by passing a user_id in get * so will be accessible only to the admin and teacher * if no user is passed, a filter will be applied to check if * its the current user trying to view his/her own marksheet or * if its the parant trying to view the marksheet of their pupil */ public function action_index() { $relevant_user = Acl::instance()->relevant_user(); if (!$relevant_user) { echo 'Not allowed'; exit; } $user = Auth::instance()->get_user(); $course_ids = $user->courses->find_all()->as_array(NULL, 'id'); if ($course_ids) { $exams = ORM::factory('exam'); $exams->where('course_id', 'IN', $course_ids)->group_by('examgroup_id'); $exams = $exams->find_all()->as_array(NULL, 'examgroup_id'); if ($exams) { $examgroups = ORM::factory('examgroup'); $examgroups->where('publish', '=', '1'); $examgroups->where('id', 'IN', $exams)->group_by('id'); $examgroups = $examgroups->find_all(); } else { $examgroups = ""; } } else { $examgroups = ""; } $view = View::factory('examresult/index')->bind('examgroup', $examgroups); $this->content = $view; }
public function before() { parent::before(); $auth = \Auth::instance('SimpleAuth'); if (\Input::get('logout')) { $auth->logout(); \Response::redirect(\Uri::base(false) . 'admin/login'); } $uri = explode('/', \Uri::string()); if ($auth->check()) { if (count($uri) < 3 && (empty($uri[1]) || $uri[1] == 'login')) { \Response::redirect(\Uri::base(false) . 'admin/list'); } // Load admin Config for List View and default to first tab $this->data['tabs'] = $this->template->tabs = \Config::get('admin.tabs'); $this->data['table'] = $this->param('item', ''); // get item from URI if (!$this->data['table']) { list($this->data['table']) = array_slice(array_keys($this->data['tabs']), 0, 1); } $this->template->table = $this->data['table']; } elseif (count($uri) > 1 && $uri[1] != 'login') { \Response::redirect(\Uri::base(false) . 'admin/login'); } if ($this->auto_render === true) { // set up defaults $this->template->body = ''; } return true; }
public function action_login() { // Already logged in Auth::check() and Response::redirect('admin'); $val = Validation::forge(); if (Input::method() == 'POST') { $val->add('email', 'ユーザ名')->add_rule('required'); $val->add('password', 'パスワード')->add_rule('required'); if ($val->run()) { $auth = Auth::instance(); // check the credentials. This assumes that you have the previous table created if (Auth::check() or $auth->login(Input::post('email'), Input::post('password'))) { // credentials ok, go right in if (Config::get('auth.driver', 'Simpleauth') == 'Ormauth') { $current_user = Model\Auth_User::find_by_username(Auth::get_screen_name()); } else { $current_user = Model_User::find_by_username(Auth::get_screen_name()); } Session::set_flash('success', e('ようこそ、' . $current_user->username . 'さん')); Response::redirect('admin'); } else { $this->template->set_global('login_error', '失敗しました'); } } } $this->template->title = 'ログイン'; $this->template->content = View::forge('admin/login', array('val' => $val), false); }
public function preExecute() { $sessionVariableManager = new DatabaseSessionManager(); $sessionVariableManager->setSessionVariables(array('orangehrm_user' => Auth::instance()->getLoggedInUserId())); $sessionVariableManager->registerVarables(); $this->setOperationName(OrangeActionHelper::getActionDescriptor($this->getModuleName(), $this->getActionName())); }
/** * Automatically executed before the widget action. Can be used to set * class properties, do authorization checks, and execute other custom code. * * @return void */ public function before() { // get all categories if ($this->categories != FALSE) { $this->cat_items = Model_Category::get_as_array(); $this->cat_order_items = Model_Category::get_multidimensional(); } // get all locations if ($this->locations != FALSE) { $this->loc_items = Model_Location::get_as_array(); $this->loc_order_items = Model_Location::get_multidimensional(); } if ($this->price != FALSE) { $this->price = TRUE; } // user if (Auth::instance()->logged_in()) { //subscriber // check if user is already subscribed $user_id = Auth::instance()->get_user()->id_user; $obj_subscriber = new Model_Subscribe(); $subscriber = $obj_subscriber->where('id_user', '=', $user_id)->limit(1)->find(); if ($subscriber->loaded()) { $this->subscriber = TRUE; } //if user logged in pass email and id $this->user_email = Auth::instance()->get_user()->email; $this->user_id = $user_id; } else { $this->user_id = 0; } //min - max price selected $this->min_price = $this->min_price; $this->max_price = $this->max_price; }
/** * The before() method is called before your controller action. * In our template controller we override this method so that we can * set up default values. These variables are then available to our * controllers if they need to be modified. */ public function before() { //Run any before if needed parent::before(); //Open session $this->session = Session::instance(); //Check user auth and role $action_name = Request::instance()->action; if (is_array($this->secure_actions) && array_key_exists($action_name, $this->secure_actions) && Auth::instance()->logged_in($this->secure_actions[$action_name]) === FALSE) { if (Auth::instance()->logged_in()) { Request::instance()->redirect('admin/site/noaccess'); } else { Request::instance()->redirect('admin/site/signin'); } } if ($this->auto_render) { // Initialize empty values $this->template->title = ''; $this->template->meta_keywords = ''; $this->template->meta_description = ''; $this->template->meta_copywrite = ''; $this->template->header = ''; $this->template->content = ''; $this->template->footer = ''; $this->template->styles = array(); $this->template->scripts = array(); $this->template->section_title = ' '; } }
public function action_logout() { // Log user out Auth::instance()->logout(); // Redirect to login page $this->redirect('welcome/login'); }
public function before() { parent::before(); if (!Auth::instance()->logged_in("admin")) { $this->redirect("/"); } }
public function action_logout() { // log user out Auth::instance()->logout(); // redirect to login page Request::current()->redirect(''); }
public function action_addpost() { if (!Auth::instance()->logged_in()) { $this->request->redirect("admin"); } $news = Model::factory("post"); $this->template->scripts = array('/js/admin/post.js'); if (!empty($_POST)) { // сохранение поста $post['dates'] = $_POST['d']['date']; $post['language'] = "ru"; $post['publ'] = $_POST['d']['publ']; $post['name'] = $_POST['d']['name']; $post['title'] = $_POST['d']['title']; $post['keywords'] = $_POST['d']['keys']; $post['description'] = $_POST['d']['description']; $post['anons'] = $_POST['d']['anons']; $post['content'] = $_POST['d']['content']; $post['image'] = $_POST['d']['image']; $res = $news->saveNewPost($post); //if($res){ $this->request->redirect("adminPost"); //} $this->template->content = View::factory('admin/post/edit.tpl', array("post" => $post)); } $this->template->content = View::factory('admin/post/edit.tpl'); }
public function __construct() { parent::__construct(); $this->themes->validator_enabled = TRUE; // Is the Admin Logged In? $this->logged_in = Auth::instance()->logged_in(); }
/** * generates HTML form * @param Model_Product $order * @return string */ public static function form(Model_Order $order) { if (Core::config('payment.authorize_login') != '' and Core::config('payment.authorize_key') != '' and Auth::instance()->logged_in() and $order->loaded() and Theme::get('premium') == 1) { return View::factory('pages/authorize/form', array('order' => $order)); } return ''; }
/** * Get the current user * @Developer Brandon Hansen * @Date April 05, 2010 * @Return User_Model */ public static function current() { if (!self::$user) { self::$user = Auth::instance()->get_user(); } return self::$user; }
public function on_page_load() { $username = Auth::get_username(); Auth::instance()->logout(TRUE); Observer::notify('admin_after_logout', $username); HTTP::redirect($this->get('next_url', Request::current()->referrer())); }
public function action_repass($onepass) { if (!Model_User::count(array('where' => array('onepass' => $onepass)))) { Response::redirect('user/login/without'); } if (Input::method() == 'POST') { $val = Model_User::validate('repass'); $val->add_field('email', 'Eメール', 'required|valid_email'); if ($val->run()) { $user = Model_User::find('first', array('where' => array('onepass' => $onepass))); $last_login = mb_substr($user['last_login'], -4); $reset = Input::post('reset'); if ($last_login == $reset) { $username = Input::post('username'); $email = Input::post('email'); $password = Input::post('password'); if ($username == $user['username'] && $email == $user['email']) { $user->onepass = md5(time()); $user->save(); $auth = Auth::instance(); $old = $auth->reset_password($username); $auth->change_password($old, $password, $username); Response::redirect('user/login'); } else { Session::set_flash('na', '<p><span class="alert-error">該当者がいません</span></p>'); } } else { Session::set_flash('error', "<p>" . $val->show_errors() . "</p>"); } } return Model_User::theme('admin/template', 'user/login/repass'); } }
public function action_index($supplychain_id) { if (!is_numeric($supplychain_id)) { $supplychain_id = $this->_match_alias($supplychain_id); } $supplychain = ORM::factory('supplychain', $supplychain_id); $sc = $supplychain->kitchen_sink($supplychain_id); if ($supplychain->loaded()) { $current_user_id = Auth::instance()->logged_in() ? (int) Auth::instance()->get_user()->id : 0; $owner_id = (int) $supplychain->user_id; if ($supplychain->user_can($current_user_id, Sourcemap::READ)) { $this->layout->supplychain_id = $supplychain_id; // pass supplychain metadeta to template $this->template->supplychain_id = $supplychain_id; $this->template->supplychain_date = date('F j, Y', $sc->created); $this->template->supplychain_name = isset($sc->attributes->name) ? $sc->attributes->name : ""; $this->template->supplychain_owner = isset($sc->owner->name) ? $sc->owner->name : ""; $this->template->supplychain_ownerid = isset($sc->owner->id) ? $sc->owner->id : ""; $this->template->supplychain_avatar = isset($sc->owner->avatar) ? $sc->owner->avatar : ""; $this->template->supplychain_desc = isset($sc->attributes->description) ? $sc->attributes->description : ""; $this->layout->scripts = array('blog-view'); $this->layout->styles = array('sites/default/assets/styles/reset.css', 'assets/styles/base.less', 'assets/styles/general.less'); // qrcode url $qrcode_query = URL::query(array('q' => URL::site('view/' . $supplychain->id, true), 'sz' => 8)); $this->template->qrcode_url = URL::site('services/qrencode', true) . $qrcode_query; } else { Message::instance()->set('That map is private.'); $this->request->redirect('browse'); } } else { Message::instance()->set('That map could not be found.'); $this->request->redirect('browse'); } }
public function action_index() { //ログイン用のオブジェクト生成 $auth = Auth::instance(); $auth->logout(); Response::redirect('members'); }
/** * Initialize properties before running the controller methods (actions), * so they are available to our action. */ public function before() { // Run anything that need ot run before this. parent::before(); if (!Auth::instance()->logged_in()) { if ($this->request->controller != 'auth') { // If we want to force people to log in, // we can uncomment this line // TODO -- send some message saying (you must login!) //$this->request->redirect('index.php/auth/login'); } } if ($this->auto_render) { // Initialize empty values $this->template->title = 'Ptododactyl Rulez!'; $this->template->meta_keywords = ''; $this->template->meta_description = ''; $this->template->meta_copywrite = ''; $this->template->header = View::factory('includes/header'); $this->template->content = ''; $this->template->footer = View::factory('includes/footer'); $this->template->styles = array(); $this->template->scripts = array(); } }
public function action_login() { // Проверям, вдруг пользователь уже зашел if (Auth::instance()->logged_in()) { // И если это так, то отправляем его сразу на страницу пользователей return $this->redirect('/visiter'); } // Если же пользователь не зашел, но данные на страницу пришли, то: if ($_POST) { // Создаем переменную, отвечающую за связь с моделью данных User $user = ORM::factory('User'); // в $status помещаем результат функции login $status = Auth::instance()->login($_POST['username'], $_POST['password']); // Если логин успешен, то if ($status) { // Отправляем пользователя на его страницу $this->redirect('/visiter'); } else { // Иначе ничего не получилось, пишем failed $this->template->content = 'failed'; } } // Грузим view логина $content = View::factory('/pages/login'); $this->template->content = $content; }
/** * Add a new client */ public function action_add() { $view = View::factory('client/edit'); $view->set('title', "Add Cient"); switch ($this->request->method()) { default: case 'GET': $post = array('is_active' => 1); $view->set('post', $post); $view->set('referrer', $this->request->referrer()); $this->response->body($view); break; case 'POST': $post = $this->request->post(); $client = Model::factory('Client'); if ($client->validate($post)) { $post['entry_by'] = Auth::instance()->get_user_id(); $client->save($post); Lasku::flash("Client {$post['name']} is added."); $this->redirect('client'); } else { $view->set('post', $post); $view->set('referrer', $post['referrer']); $view->set('errors', $client->errors()); $this->response->body($view); } break; } }