Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- use \Orm\Model\Branch;
- class Controller_Default extends Controller_Template
- {
- public $template = 'default/template';
- private function after_login()
- {
- /*
- Session::set("all_branches", Model_Branch::find('all'));
- $user_fields = Auth::get_profile_fields();
- Session::set("pce_user", $user_fields);
- $user_branches = Model_Branch::find('all', array('where' => array(array('id', 'in', unserialize($user_fields['branches'])))));
- Session::set('pce_user.branches', $user_branches);
- Session::set('pce_user.active_branches', $user_branches);
- */
- PCE::login_redirect();
- }
- public function action_login()
- {
- if(Auth::check())
- {
- //already logged in
- Messages::success(__('login.already_loggedin'));
- $this->after_login();
- }
- elseif(!Input::post())
- {
- //please log in
- Messages::info(__('login.please'));
- }
- if($input = Input::post())
- {
- // check the credentials.
- if (Auth::login(Input::param('username'), Input::param('password')))
- {
- if (Input::param('remember_me', false))
- {
- //create a remember_me cookie
- Auth::remember_me();
- }
- else
- {
- //delete any remember_me cookies present
- Auth::dont_remember_me();
- }
- //login successful => set message and redirect
- Messages::success(__('login.success'));
- $this->after_login();
- }
- else
- {
- // login failed, show an error message
- \Messages::error(__('login.failure'));
- }
- }
- $this->template->title = 'PCexpres order management system » Index';
- $this->template->content = View::forge('default/index');
- }
- public function action_logout()
- {
- // remove the remember-me cookie, we logged-out on purpose
- \Auth::dont_remember_me();
- // logout
- \Auth::logout();
- // inform the user the logout was successful
- \Messages::success(__('login.logout'));
- //redirect to login
- Response::redirect('/');
- }
- public function action_404()
- {
- $data['subnav'] = array('404'=> 'active' );
- $this->template->title = 'PCexpres order management system » 404';
- $this->template->content = Presenter::forge('default/404')->set($data);
- }
- public function action_disambiguation()
- {
- if(!Auth::check())
- {
- Response::redirect('/');
- }
- $data['subnav'] = array('disambiguation'=> 'active' );
- $this->template->title = 'PCexpres order management system » Disambiguation';
- $this->template->content = View::forge('default/disambiguation')->set($data);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement