Ejemplo n.º 1
0
 public function before()
 {
     parent::before();
     // Check Auth
     if (!\Auth\Auth::check()) {
         \Fuel\Core\Response::redirect('auth');
     }
     /*
      *  Theme Set
      */
     $this->theme = \Theme::instance();
     $this->theme->set_template('index');
     /*
      * Breadcrumb
      */
     // $this->_breadcrumb = Breadcrumb::create_links();
     if (Session::get('lang')) {
         $this->_lang = Session::get('lang');
     }
     if (Input::method() == 'GET') {
         $this->_get = Input::get();
     }
     if (Input::method() == 'POST') {
         $this->_post = Input::post();
     }
     $this->initialized();
 }
Ejemplo n.º 2
0
 public function before()
 {
     parent::before();
     if (!Auth::check()) {
         Response::redirect('/');
     }
 }
Ejemplo n.º 3
0
 public function action_login()
 {
     // already logged in?
     if (Auth::check()) {
         // yes, so go back to the page the user came from, or the
         // application dashboard if no previous page can be detected
         //Messages::info(__('login.already-logged-in'));
         Response::redirect_back('');
     }
     // was the login form posted?
     if (Input::method() == 'POST') {
         // check the credentials.
         print_r(Input::all());
         if (Auth::login(Input::param('email'), Input::param('password'))) {
             // did the user want to be remembered?
             if (Input::param('remember', false)) {
                 // create the remember-me cookie
                 Auth::remember_me();
             } else {
                 // delete the remember-me cookie if present
                 Auth::dont_remember_me();
             }
             // logged in, go back to the page the user came from, or the
             // application dashboard if no previous page can be detected
             Response::redirect_back('/home');
         } else {
             // login failed, show an error message
             $this->error = 'test';
         }
     }
     // display the login page
     return \View::forge('auth/login');
 }
Ejemplo n.º 4
0
 public function action_index()
 {
     if (Auth::check()) {
         return Response::redirect('admin/home');
     } else {
         return Response::redirect('admin/login');
     }
 }
Ejemplo n.º 5
0
 public function logout()
 {
     if (Auth::check()) {
         Auth::logout();
     }
     //redirect to home page
     redirect();
 }
Ejemplo n.º 6
0
 public function before()
 {
     parent::before();
     // Without this line, templating won't work!
     $this->template->head = View::forge('_partial/head');
     $this->template->header = View::forge('_partial/header');
     $this->template->footer = View::forge('_partial/footer');
     if (!Auth::check()) {
         Response::redirect('/auth/login');
     }
     // do stuff
 }
Ejemplo n.º 7
0
 public function action_index()
 {
     //すでにログイン済であればログイン後のページへリダイレクト
     Auth::check() and Response::redirect('top');
     //エラーメッセージ用変数初期化
     $error = null;
     //ログイン用のオブジェクト生成
     $auth = Auth::instance();
     //ログインボタンが押されたら、ユーザ名、パスワードをチェックする
     if (Input::post()) {
         if ($auth->login(Input::post('username'), Input::post('password'))) {
             // ログイン成功時、ログイン後のページへリダイレクト
             Response::redirect('top');
         } else {
             // ログイン失敗時、エラーメッセージ作成
             $error = 'ユーザ名かパスワードに誤りがあります';
         }
     }
     //ビューテンプレートを呼び出し
     $this->template->content = View::forge('login/index');
     //エラーメッセージをビューにセット
     $this->template->content->set('error', $error);
     $this->template->title = "login";
 }
Ejemplo n.º 8
0
 public function action_forgot()
 {
     \Auth\Auth::check() and \Fuel\Core\Response::redirect("user");
     $val = \Fuel\Core\Validation::forge('forgot');
     if (\Fuel\Core\Input::method() == "POST") {
         if ($val->run()) {
             try {
                 $username = \Fuel\Core\Input::post('email');
                 $user = Model_User::find('first', array('where' => array(array('username', 'LIKE', "{$username}"), 'or' => array(array('email', 'LIKE', "{$username}")))));
                 if (!$user) {
                     throw new \Auth\SimpleUserUpdateException("Invalid username or email");
                 }
                 $old_password = \Auth\Auth::reset_password($user->username);
                 $new_password = \Fuel\Core\Str::random();
                 \Auth\Auth::update_user(array('password' => $new_password, 'old_password' => $old_password), $user->username);
                 // Create an instance
                 $email = \Email\Email::forge();
                 // Set the from address
                 $email->from('*****@*****.**', 'ITNT Time Sheets');
                 // Set the to address
                 $email->to($user->email, $user->first_name . " " . $user->last_name);
                 // Set a subject
                 $email->subject('ITNT Time Sheets Password Reset');
                 // Set multiple to addresses
                 //                            $email->bcc(array(
                 //                                '*****@*****.**' => 'Gavin Murambadoro',
                 //                            ));
                 // Set a html body message
                 $email->html_body(\View::forge('includes/email/forgot', array('user' => $user, 'password' => $new_password)));
                 if ($email->send()) {
                     $this->template->set_global('login_success', "Your password has been reset and an email was sent to {$user->email}");
                 } else {
                     $this->template->set_global('login_error', "Your password was reset but we could not send you an email. Your new password is {$new_password}. Make sure that you copy this before leaving this page.");
                 }
             } catch (\SimpleUserUpdateException $exception) {
                 $this->template->set_global('login_error', "User Error: {$exception->getMessage()}");
             } catch (\EmailValidationFailedException $exception) {
                 $this->template->set_global('login_error', "Mail Validation Error: {$exception->getMessage()}");
             } catch (\EmailSendingFailedException $exception) {
                 $this->template->set_global('login_error', "Mail Error: {$exception->getMessage()}");
             } catch (Exception $exception) {
                 $this->template->set_global('login_error', "General Error: {$exception->getMessage()}");
             }
         } else {
             $this->template->set_global('login_error', $val->error());
         }
     }
     $this->template->set_global('val', $val, false);
     $this->template->title = 'Forgot Password';
     $this->template->content = View::forge('user/forgot');
 }
Ejemplo n.º 9
0
 function getNavTop()
 {
     if (Auth::check()) {
         return ['view' => 'nav_top_logged.php', 'name' => Auth::user()->name];
     }
     return ['view' => 'nav_top_not_login.php'];
 }
Ejemplo n.º 10
0
 public static function is_login()
 {
     return Auth::check();
 }