Esempio n. 1
0
 public function action_login()
 {
     // Already logged in
     Auth::check() and Response::redirect('admin');
     $val = Validation::forge();
     if (Input::method() == 'POST') {
         $val->add('email', 'Email or Username')->add_rule('required');
         $val->add('password', 'Password')->add_rule('required');
         if ($val->run()) {
             if (!Auth::check()) {
                 if (Auth::login(Input::post('email'), Input::post('password'))) {
                     // assign the user id that lasted updated this record
                     foreach (\Auth::verified() as $driver) {
                         if (($id = $driver->get_user_id()) !== false) {
                             // credentials ok, go right in
                             $current_user = Model\Auth_User::find($id[1]);
                             Session::set_flash('success', e('Welcome, ' . $current_user->username));
                             Response::redirect_back('admin');
                         }
                     }
                 } else {
                     $this->template->set_global('login_error', 'Login failed!');
                 }
             } else {
                 $this->template->set_global('login_error', 'Already logged in!');
             }
         }
     }
     $this->template->title = 'ITNT Timesheets Login';
     $this->template->content = View::forge('admin/login', array('val' => $val), false);
 }
Esempio n. 2
0
 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);
 }
Esempio n. 3
0
 public function post_login()
 {
     $val = Validation::forge();
     $val->add('email', 'Email or Username')->add_rule('required');
     $val->add('password', 'Password')->add_rule('required');
     if ($val->run()) {
         if (!Auth::check()) {
             if (Auth::login(Input::post('email'), Input::post('password'))) {
                 // assign the user id that lasted updated this record
                 foreach (\Auth::verified() as $driver) {
                     if (($id = $driver->get_user_id()) !== false) {
                         $result = [];
                         $result['current_user'] = Model\Auth_User::find($id[1])->username;
                         $result['current_bidder'] = \Config::get('my.yahoo.user_name');
                         $this->response(['status_code' => $this->_status_code['login_success'], 'result' => $result]);
                     }
                 }
             } else {
                 $this->response(['status_code' => $this->_status_code['login_faild']]);
             }
         } else {
             $this->response(['status_code' => $this->_status_code['alredy_logedin']]);
         }
     } else {
         $this->response(['status_code' => $this->_status_code['login_faild']]);
     }
 }
Esempio n. 4
0
 public function before()
 {
     parent::before();
     // Assign current_user to the instance so controllers can use it
     $this->current_user = Auth::check() ? Config::get('auth.driver', 'Simpleauth') == 'Ormauth' ? Model\Auth_User::find_by_username(Auth::get_screen_name()) : Model_User::find_by_username(Auth::get_screen_name()) : null;
     // Set a global variable so views can use it
     View::set_global('current_user', $this->current_user);
 }
 public function before()
 {
     parent::before();
     $this->current_user = null;
     foreach (\Auth::verified() as $driver) {
         if (($id = $driver->get_user_id()) !== false) {
             $this->current_user = Model\Auth_User::find($id[1]);
         }
         break;
     }
     // Set a global variable so views can use it
     View::set_global('current_user', $this->current_user);
 }
Esempio n. 6
0
 public function before()
 {
     if (Agent::is_mobiledevice()) {
         \Response::redirect('mobile/index.html');
     }
     parent::before();
     foreach (\Auth::verified() as $driver) {
         if (($id = $driver->get_user_id()) !== false) {
             $this->current_user = Model\Auth_User::find($id[1]);
         }
         break;
     }
     // Set a global variable so views can use it
     View::set_global('current_user', $this->current_user);
 }