Example #1
0
 /**
  * default action 'index'
  * @param Request $request
  * @param Response $response
  */
 public function index(Request $request, Response $response)
 {
     if (Common_Model::admin_logined()) {
         $response->redirect('/home');
     } else {
         $response->redirect('/login');
     }
 }
Example #2
0
 public function resolveRoute()
 {
     $request_uri = $this->request->request_uri();
     if ($request_uri != '/') {
         $controllerName = $this->getControllerName($request_uri);
         if (strpos($controllerName, '\\')) {
             return $controllerName;
         }
         return $this->namespace . '\\' . $controllerName;
     }
     $this->response->redirect(Response::REDIRECT_LOGIN);
 }
Example #3
0
 /**
  * The index action
  * 
  * @access public
  * @return void
  */
 public function action_index()
 {
     $settings = \Config::load('autoresponder.db');
     // $autoResponder = Model_Setting::find(array('where' => array(array('meta_key', '=', 'auto-responders'))));
     if (\Input::post()) {
         $input = \Input::post();
         if (!\Input::is_ajax()) {
             $val = Model_Setting::validate('create');
             if (!$val->run()) {
                 if ($val->error() != array()) {
                     // show validation errors
                     \Messages::error('<strong>There was an error while trying to create settings</strong>');
                     foreach ($val->error() as $e) {
                         \Messages::error($e->get_message());
                     }
                 }
             } else {
                 try {
                     \Config::save('autoresponder.db', array('logo_url' => $input['logo_url'], 'company_name' => $input['company_name'], 'address' => $input['address'], 'website' => $input['website'], 'phone' => $input['phone'], 'email_address' => $input['email_address'], 'sender_email_address' => $input['sender_email_address'], 'contact_us_email_address' => $input['contact_us_email_address'], 'instagram_account_name' => $input['instagram_account_name'], 'facebook_account_name' => $input['facebook_account_name']));
                     // $setting->save();
                     \Messages::success('Settings successfully created.');
                     \Response::redirect('admin/settings');
                 } catch (\Database_Exception $e) {
                     // show validation errors
                     \Messages::error('<strong>There was an error while trying to create settings.</strong>');
                     // Uncomment lines below to show database errors
                     $errors = $e->getMessage();
                     \Messages::error($errors);
                 }
             }
         }
     }
     \View::set_global('title', 'Settings');
     \Theme::instance()->set_partial('content', $this->view_dir . 'index')->set('settings', $settings, false);
 }
Example #4
0
 /**
  * @param   none
  * @throws  none
  * @returns	void
  */
 public function before()
 {
     $result = array();
     // users need to be logged in to access this controller
     if (!\Sentry::check()) {
         $result = array('message' => 'You need to be logged in to access that page.', 'url' => '/admin/login');
         // Don't show this message if url is just 'admin'
         if (\Uri::string() == 'admin/admin/index') {
             unset($result['message']);
         }
         \Session::set('redirect_to', \Uri::admin('current'));
     } else {
         if (!\Sentry::user()->is_admin()) {
             $result = array('message' => 'Access denied. You need to be a member of staff to access that page.', 'url' => '/admin/login');
             \Session::set('redirect_to', \Uri::admin('current'));
         }
     }
     if (!empty($result)) {
         if (\Input::is_ajax()) {
             \Messages::error('You need to be logged in to complete this action.');
             echo \Messages::display('left', false);
             exit;
         } else {
             if (isset($result['message'])) {
                 \Messages::warning($result['message']);
             }
             \Response::redirect($result['url']);
         }
     }
     parent::before();
 }
Example #5
0
 public function action_edit($id = null)
 {
     parent::has_access("create_employee");
     is_null($id) and Response::redirect('employees/view' . $id);
     if (!($bank = Model_Bank::find('first', array('where' => array('employee_id' => $id))))) {
         Session::set_flash('error', 'Could not find user #' . $id);
         Response::redirect('employees/view/' . $id);
     }
     if (Input::method() == 'POST') {
         $bank->account_no = Input::post('account_no');
         $bank->account_type = Input::post('account_type');
         $bank->branch = Input::post('branch');
         $bank->city = Input::post('city');
         $bank->state = Input::post('state');
         $bank->ifsc_code = Input::post('ifsc_code');
         $bank->payment_type = Input::post('payment_type');
         if ($bank->save()) {
             Session::set_flash('success', 'Updated bank details #' . $id);
             Response::redirect('employees/view/' . $id);
         } else {
             Session::set_flash('error', 'Could not update bank #' . $id);
         }
     }
     $this->template->title = "Banks";
     $this->template->content = View::forge('banks/edit');
 }
 /**
  * @runInSeparateProcess
  */
 public function testRedirect()
 {
     $response = new Response($this->makeRequest());
     $response->exitAfterRedirect(false);
     $response->redirect('test.php', false);
     $this->assertContains('Location: test.php', xdebug_get_headers());
 }
Example #7
0
 public function action_edit($id = null)
 {
     $student = Model_Student::find('first', ['where' => ['user_id' => $id]]);
     if (!$student) {
         $student = Model_Student::forge(['user_id' => $id]);
     }
     $val = Model_Student::validate('edit');
     if ($val->run()) {
         $student->user_id = Input::post('user_id');
         $student->year_level = Input::post('year_level');
         $student->course_id = Input::post('course_id');
         if ($student->save()) {
             Session::set_flash('success', e('Updated student #' . $id));
             Response::redirect('site/student');
         } else {
             Session::set_flash('error', e('Could not update student #' . $id));
         }
     } else {
         if (Input::method() == 'POST') {
             $student->user_id = $val->validated('user_id');
             $student->year_level = $val->validated('year_level');
             $student->course_id = $val->validated('course_id');
             Session::set_flash('error', $val->error());
         }
         $this->template->set_global('student', $student, false);
     }
     $this->template->title = "Students";
     $this->template->content = View::forge('site/student/edit');
 }
Example #8
0
File: date.php Project: sajans/cms
 public function action_edit($id = null)
 {
     is_null($id) and Response::redirect('date');
     if (!($date = Model_Date::find($id))) {
         Session::set_flash('error', 'Could not find Date' . $id);
         Response::redirect('date');
     }
     $val = Model_Date::validate('date');
     if ($val->run()) {
         $date->title = Input::post('title');
         $date->summary = Input::post('summary');
         $date->date = strtotime(Input::post('date'));
         $date->date_keywords = Input::post('date_keywords');
         if ($date->save()) {
             Session::set_flash('success', 'Updated Dates #' . $id);
             Response::redirect('admin/date');
         } else {
             Session::set_flash('error', 'Could not update date #' . $id);
         }
     } else {
         if (Input::method() == 'POST') {
             $date->title = Input::post('title');
             $date->summary = Input::post('summary');
             $date->date = Input::post('date');
             $date->date_keywords = Input::post('date_keywords');
             Session::set_flash('error', $val->error());
         }
         $this->template->set_global('date', $date, false);
     }
     $this->template->title = "Dates";
     $this->template->content = View::forge('admin/date/create');
 }
Example #9
0
 public function action_new()
 {
     $data = [];
     if (Input::post("firstname", null) != null and Security::check_token()) {
         $email = Input::post("email", null);
         if ($email != $this->user->email) {
             $check_user = Model_User::find("first", ["where" => [["email" => $email]]]);
             if ($check_user == null) {
                 $this->email = $email;
             } else {
                 $data["error"] = "This email is already in use.";
             }
         }
         if (!isset($data["error"])) {
             $this->user->firstname = Input::post("firstname", "");
             $this->user->middlename = Input::post("middlename", "");
             $this->user->lastname = Input::post("lastname", "");
             $this->user->google_account = Input::post("google_account", "");
             $this->user->password = Auth::instance()->hash_password(Input::post('password', ""));
             $this->user->birthday = Input::post("year") . "-" . Input::post("month") . "-" . Input::post("day");
             $this->user->google_account = Input::post("google_account");
             $this->user->need_reservation_email = Input::post("need_reservation_email");
             $this->user->need_news_email = Input::post("need_news_email");
             $this->user->timezone = Input::post("timezone");
             $this->user->save();
             Response::redirect("students");
         }
     }
     $data['pasts'] = Model_Lessontime::find("all", ["where" => [["student_id", $this->user->id], ["status", 2], ["language", Input::get("course", 0)], ["deleted_at", 0]]]);
     $data["donetrial"] = Model_Lessontime::find("all", ["where" => [["student_id", $this->user->id], ["status", 2], ["language", Input::get("course", -1)], ["deleted_at", 0]]]);
     $view = View::forge("students/setting_new", $data);
     $this->template->content = $view;
 }
Example #10
0
 /**
  * Mmeber setting timeline_view
  * 
  * @access  public
  * @return  Response
  */
 public function action_viewtype()
 {
     $page_name = term('timeline', 'site.view', 'site.setting');
     $val = \Form_MemberConfig::get_validation($this->u->id, 'timeline_viewType');
     if (Input::method() == 'POST') {
         Util_security::check_csrf();
         try {
             if (!$val->run()) {
                 throw new \FuelException($val->show_errors());
             }
             $post = $val->validated();
             \DB::start_transaction();
             \Form_MemberConfig::save($this->u->id, $val, $post);
             \DB::commit_transaction();
             \Session::set_flash('message', $page_name . 'を変更しました。');
             \Response::redirect('member/setting');
         } catch (\FuelException $e) {
             if (\DB::in_transaction()) {
                 \DB::rollback_transaction();
             }
             \Session::set_flash('error', $e->getMessage());
         }
     }
     $this->set_title_and_breadcrumbs($page_name, array('member/setting' => term('site.setting', 'form.update')), $this->u);
     $this->template->content = \View::forge('member/setting/timeline_viewtype', array('val' => $val));
 }
Example #11
0
 public function action_usercp()
 {
     if (!$this->current_user->logged_in()) {
         Session::set_flash('error', 'You need to be logged in to access is page');
         Session::set_flash('login_redirect', Uri::current());
         Response::redirect('login');
     }
     $this->title('UserCP');
     $this->view = $this->theme->view('users/usercp');
     if (Input::param() != array()) {
         // Set name and email
         $this->current_user->name = Input::param('name');
         $this->current_user->email = Input::param('email');
         // Set new password
         if (Input::param('new_password')) {
             $this->current_user->password = Input::param('new_password');
         }
         // Check if the current password is valid...
         $auth = Model_User::authenticate_login($this->current_user->username, Input::param('current_password'));
         if ($this->current_user->is_valid() and $auth) {
             $this->current_user->save();
             Session::set_flash('success', 'Details saved');
             Response::redirect('usercp');
         } else {
             $errors = $this->current_user->errors();
             if (!$auth) {
                 $errors = array('Current password is invalid.') + $errors;
             }
         }
         $this->view->set('errors', isset($errors) ? $errors : array());
     }
 }
Example #12
0
 public function action_detail($id = 0)
 {
     $data["forum"] = Model_Forum::find($id);
     if ($data["forum"] == null) {
         Response::redirect("/teachers/forum/");
     }
     if (Input::get("del_id", null) != null) {
         $del_comment = Model_Comment::find(Input::get("del_id", 0));
         if ($del_comment->user_id == $this->user->id) {
             $del_comment->deleted_at = time();
             $del_comment->save();
         }
     }
     // add
     if (Input::post("body", "") != "" and Security::check_token()) {
         // save
         $comment = Model_Comment::forge();
         $comment->body = Input::post("body", "");
         $comment->forum_id = $id;
         $comment->user_id = $this->user->id;
         $comment->save();
     }
     $data["user"] = $this->user;
     $view = View::forge("teachers/forum/detail", $data);
     $this->template->content = $view;
 }
Example #13
0
 public function action_submit()
 {
     if (!Security::check_token()) {
         Response::redirect('_404_');
     }
     if (Session::get_flash('name')) {
         $contact = Model_Contact::forge();
         $contact->title = Session::get_flash("title");
         $contact->body = Session::get_flash("body");
         $body = View::forge("email/contact");
         $body->set("name", Session::get_flash('name'));
         $body->set("email", Session::get_flash('email'));
         $body->set("body", Session::get_flash('body'));
         $sendmail = Email::forge("JIS");
         $sendmail->from(Config::get("statics.info_email"), Config::get("statics.info_name"));
         $sendmail->to(Config::get("statics.info_email"));
         $sendmail->subject("We got contact/ Game-bootcamp");
         $sendmail->body($body);
         $sendmail->send();
     }
     $this->template->title = "Contact";
     $this->template->sub = "How can we help you?";
     $view = View::forge("contacts/send");
     $this->template->content = $view;
 }
Example #14
0
 public function action_edit($id = null, $one = null, $two = null)
 {
     $redirect = $two ? $one . '/' . $two : $one;
     $auction = Model_Auction::find($id);
     $val = Model_Auction::validate_edit();
     if ($val->run()) {
         $auction->item_count = Input::post('item_count');
         $auction->price = Input::post('price');
         $auction->memo = Input::post('memo');
         if (\Security::check_token() && $auction->save()) {
             Session::set_flash('success', e('Updated auction #' . $auction->auc_id));
             Response::redirect('admin/' . $redirect);
         } else {
             Session::set_flash('error', e('Could not update auction #' . $auction->auc_id));
         }
     } else {
         if (Input::method() == 'POST') {
             $auction->item_count = $val->validated('item_count');
             $auction->price = $val->validated('price');
             $auction->memo = $val->validated('memo');
             Session::set_flash('error', $val->error());
         }
         $this->template->set_global('auction', $auction, false);
     }
     $this->template->set_global('redirect', $redirect, false);
     $this->template->title = $auction->title;
     $this->template->content = View::forge('admin/auction/edit');
 }
Example #15
0
 /**
  * The basic welcome message
  *
  * @access  public
  * @return  Response
  */
 public function action_index()
 {
     if (!\Auth::check()) {
         return \Response::redirect('cmsadmin/auth/index');
     }
     return \Response::forge(\View::forge('welcome/index'));
 }
Example #16
0
File: user.php Project: vano00/jobs
 public function action_edit()
 {
     $data['user'] = \Auth::get_profile_fields();
     $data['user']['email'] = \Auth::get_email();
     if (\Input::post()) {
         $user = \Input::post();
         $val = \Validation::forge();
         $val->add_field('fullname', 'fullname', 'required');
         if (\Input::post('password')) {
             $val->add_field('password', 'new password', 'required|min_length[3]|max_length[10]');
             $val->add_field('old_password', 'old password', 'required|min_length[3]|max_length[10]');
         }
         $val->add_field('email', 'email', 'required|valid_email');
         if ($val->run()) {
             if ($user['password'] === '') {
                 \Auth::update_user(array('email' => $user['email'], 'fullname' => $user['fullname']));
             } else {
                 \Auth::update_user(array('email' => $user['email'], 'password' => $user['password'], 'old_password' => $user['old_password'], 'fullname' => $user['fullname']));
             }
             \Session::set_flash('success', 'The profile has been successfully updated');
             \Response::redirect('/user');
         } else {
             // repopulate the username field and give some error text back to the view.
             $data['user'] = ['fullname' => $user['fullname'], 'email' => $user['email'], 'password' => $user['password'], 'old_password' => $user['old_password']];
             \Session::set_flash('error', $val->error());
         }
     }
     $data['actions'] = ['back' => ['label' => 'Back', 'url' => '/user']];
     $this->template->title = "Edit profile";
     $this->template->content = View::forge('user/edit.twig', $data);
 }
 /**
  * Because Paypal Ipn is redirected to \Payment\PayPal\ipn
  * There is no need to notify customer here, we'll do that in Ipn method of Payment module
  */
 public function notify()
 {
     $config = array('mode' => $this->config['mode'], 'acct1.UserName' => $this->config['user_name'], 'acct1.Password' => $this->config['password'], 'acct1.Signature' => $this->config['signature']);
     $paypalService = new \PayPal\Service\PayPalAPIInterfaceServiceService($config);
     $getExpressCheckoutDetailsRequest = new \PayPal\PayPalAPI\GetExpressCheckoutDetailsRequestType(\Session::get('paypal.token'));
     $getExpressCheckoutDetailsRequest->Version = $this->config['version'];
     $getExpressCheckoutReq = new \PayPal\PayPalAPI\GetExpressCheckoutDetailsReq();
     $getExpressCheckoutReq->GetExpressCheckoutDetailsRequest = $getExpressCheckoutDetailsRequest;
     $getECResponse = $paypalService->GetExpressCheckoutDetails($getExpressCheckoutReq);
     // COMMIT THE PAYMENT
     $paypalService = new \PayPal\Service\PayPalAPIInterfaceServiceService($config);
     $paymentDetails = new \PayPal\EBLBaseComponents\PaymentDetailsType();
     $orderTotal = new \PayPal\CoreComponentTypes\BasicAmountType($this->config['currency'], $this->getOrderTotal());
     $paymentDetails->OrderTotal = $orderTotal;
     $paymentDetails->PaymentAction = 'Sale';
     $paymentDetails->NotifyURL = $this->config['notify_url'];
     $DoECRequestDetails = new \PayPal\EBLBaseComponents\DoExpressCheckoutPaymentRequestDetailsType();
     $DoECRequestDetails->PayerID = $getECResponse->GetExpressCheckoutDetailsResponseDetails->PayerInfo->PayerID;
     $DoECRequestDetails->Token = $getECResponse->GetExpressCheckoutDetailsResponseDetails->Token;
     $DoECRequestDetails->PaymentDetails[0] = $paymentDetails;
     $DoECRequest = new \PayPal\PayPalAPI\DoExpressCheckoutPaymentRequestType();
     $DoECRequest->DoExpressCheckoutPaymentRequestDetails = $DoECRequestDetails;
     $DoECRequest->Version = $this->config['version'];
     $DoECReq = new \PayPal\PayPalAPI\DoExpressCheckoutPaymentReq();
     $DoECReq->DoExpressCheckoutPaymentRequest = $DoECRequest;
     $DoECResponse = $paypalService->DoExpressCheckoutPayment($DoECReq);
     if ($DoECResponse->Ack == 'Success') {
         $this->savePayment('Completed', 'Completed', $DoECResponse->toXMLString());
         \Response::redirect(\Uri::create('order/checkout/finalise_order'));
     }
     $this->savePayment('Failed', 'Transaction failed', $DoECResponse->Errors[0]->LongMessage);
     return true;
     // failed
 }
Example #18
0
 public function action_detail($id = 0)
 {
     $data['pasts'] = Model_Lessontime::find("all", ["where" => [["student_id", $this->user->id], ["status", 2], ["language", Input::get("course", 0)], ["deleted_at", 0]]]);
     $data["donetrial"] = Model_Lessontime::find("all", ["where" => [["student_id", $this->user->id], ["status", 2], ["language", Input::get("course", -1)], ["deleted_at", 0]]]);
     $data["forum"] = Model_Forum::find($id);
     if ($data["forum"] == null) {
         Response::redirect("/students/forum/");
     }
     if (Input::get("del_id", null) != null) {
         $del_comment = Model_Comment::find(Input::get("del_id", 0));
         if ($del_comment->user_id == $this->user->id) {
             $del_comment->deleted_at = time();
             $del_comment->save();
         }
     }
     // add
     if (Input::post("body", "") != "" and Security::check_token()) {
         // save
         $comment = Model_Comment::forge();
         $comment->body = Input::post("body", "");
         $comment->forum_id = $id;
         $comment->user_id = $this->user->id;
         $comment->save();
     }
     $data["user"] = $this->user;
     $view = View::forge("students/forum/detail", $data);
     $this->template->content = $view;
 }
Example #19
0
 public function before()
 {
     parent::before();
     if (!$this->is_validated) {
         return Response::redirect('/authenticate/login');
     }
 }
Example #20
0
 public function action_callback()
 {
     // Opauth can throw all kinds of nasty bits, so be prepared
     try {
         // get the Opauth object
         $opauth = \Auth_Opauth::forge(false);
         // and process the callback
         $status = $opauth->login_or_register();
         // fetch the provider name from the opauth response so we can display a message
         $provider = $opauth->get('auth.provider', '?');
         // deal with the result of the callback process
         switch ($status) {
             // a local user was logged-in, the provider has been linked to this user
             case 'linked':
                 // inform the user the link was succesfully made
                 // and set the redirect url for this status
                 $url = '/students';
                 break;
                 // the provider was known and linked, the linked account as logged-in
             // the provider was known and linked, the linked account as logged-in
             case 'logged_in':
                 // inform the user the login using the provider was succesful
                 // and set the redirect url for this status
                 $url = '/students';
                 break;
                 // we don't know this provider login, ask the user to create a local account first
             // we don't know this provider login, ask the user to create a local account first
             case 'register':
                 // inform the user the login using the provider was succesful, but we need a local account to continue
                 // and set the redirect url for this status
                 $user_hash = \Session::get('auth-strategy.user', array());
                 $name = $user_hash['name'];
                 $email = time() . sha1($name) . '@game-bootcamp.com';
                 $password = sha1("aaaa2ht" . time());
                 $id = Auth::create_user($email, $password, $email, $group = 1);
                 Auth::force_login($id);
                 $this->link_provider($id);
                 $url = '/students/auth/oauth/' . strtolower($provider);
                 //$url = '/students';
                 break;
                 // we didn't know this provider login, but enough info was returned to auto-register the user
             // we didn't know this provider login, but enough info was returned to auto-register the user
             case 'registered':
                 // inform the user the login using the provider was succesful, and we created a local account
                 // and set the redirect url for this status
                 $url = '/students';
                 break;
             default:
                 throw new \FuelException('Auth_Opauth::login_or_register() has come up with a result that we dont know how to handle.');
         }
         // redirect to the url set
         Response::redirect($url);
     } catch (\OpauthException $e) {
         Log::error($e->getMessage());
         \Response::redirect_back();
     } catch (\OpauthCancelException $e) {
         // you should probably do something a bit more clean here...
         exit('It looks like you canceled your authorisation.' . \Html::anchor('users/oath/' . $provider, 'Click here') . ' to try again.');
     }
 }
Example #21
0
 /**
  * Mmeber_profile edit
  * 
  * @access  public
  * @return  Response
  */
 public function action_edit($type = null)
 {
     list($type, $is_regist) = self::validate_type($type, $this->u->id);
     $form_member_profile = new Form_MemberProfile($type == 'regist' ? 'regist-config' : 'config', $this->u);
     $form_member_profile->set_validation();
     if (\Input::method() == 'POST') {
         \Util_security::check_csrf();
         try {
             $form_member_profile->validate(true);
             \DB::start_transaction();
             $form_member_profile->seve();
             if ($is_regist) {
                 Model_MemberConfig::delete_value($this->u->id, 'terms_un_agreement');
             }
             \DB::commit_transaction();
             $message = $is_regist ? sprintf('%sが%sしました。', term('site.registration'), term('form.complete')) : term('profile') . 'を編集しました。';
             $redirect_uri = $is_regist ? $this->after_auth_uri : 'member/profile';
             \Session::set_flash('message', $message);
             \Response::redirect($redirect_uri);
         } catch (\FuelException $e) {
             if (\DB::in_transaction()) {
                 \DB::rollback_transaction();
             }
             \Session::set_flash('error', $e->getMessage());
         }
     }
     $this->set_title_and_breadcrumbs(term('profile') . term($is_regist ? 'site.registration' : 'form.edit'), $is_regist ? array() : array('member/profile' => term('common.my', 'profile')), $is_regist ? null : $this->u);
     $this->template->content = View::forge('member/profile/edit', array('is_regist' => $is_regist, 'val' => $form_member_profile->get_validation(), 'member_public_flags' => $form_member_profile->get_member_public_flags(), 'profiles' => $form_member_profile->get_profiles(), 'member_profile_public_flags' => $form_member_profile->get_member_profile_public_flags()));
 }
Example #22
0
 /**
  * Mmeber setting viewtype
  * 
  * @access  public
  * @return  Response
  */
 public function action_index()
 {
     $page_name = term('notice', 'site.setting');
     $val = \Form_MemberConfig::get_validation($this->u->id, 'notice', 'Notice');
     if (\Input::method() == 'POST') {
         \Util_security::check_csrf();
         try {
             if (!$val->run()) {
                 throw new \FuelException($val->show_errors());
             }
             $post = $val->validated();
             \DB::start_transaction();
             \Form_MemberConfig::save($this->u->id, $val, $post);
             \DB::commit_transaction();
             \Session::set_flash('message', $page_name . 'を変更しました。');
             \Response::redirect('member/setting');
         } catch (\FuelException $e) {
             if (\DB::in_transaction()) {
                 \DB::rollback_transaction();
             }
             \Session::set_flash('error', $e->getMessage());
         }
     }
     $this->set_title_and_breadcrumbs($page_name, array('member/setting' => term('site.setting', 'form.update')), $this->u);
     $this->template->content = \View::forge('member/setting/_parts/form', array('val' => $val, 'label_size' => 5, 'form_params' => array('common' => array('radio' => array('layout_type' => 'grid')))));
 }
Example #23
0
 /**
  * @test
  * @param $url
  * @param $statusCode
  * @dataProvider redirectDataProvider
  */
 public function testIfRedirectReturnsCorrectHttpCodeAndLocationHeader($url, $statusCode)
 {
     $response = new Response();
     $response->redirect($url, $statusCode);
     $this->assertEquals($url, $response->headers->get('Location'));
     $this->assertEquals($statusCode, $response->getStatusCode());
 }
Example #24
0
 public function action_index()
 {
     if (!Auth::check()) {
         return Response::redirect('login/');
     }
     return Response::forge(View::forge('welcome/index'));
 }
Example #25
0
 public function action_logout()
 {
     if (\CMF\Auth::logout()) {
         \Session::delete('cmf.admin.language');
         \Response::redirect('/admin/login', 'location');
     }
 }
Example #26
0
 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;
 }
Example #27
0
 public function before()
 {
     parent::before();
     if (!Auth::check()) {
         Response::redirect('login');
     }
 }
 public function action_addtask($project_id)
 {
     if (!($project = Model_Project::find($project_id))) {
         \Fuel\Core\Session::set_flash('error', "Cannot find the selected project # {$project_id}");
         \Fuel\Core\Response::redirect_back('user/projects');
     }
     $val = Model_Projecttask::validate('create');
     if (\Fuel\Core\Input::method() == 'POST') {
         if ($val->run()) {
             $projecttask = Model_Projecttask::forge(array('project_id' => Input::post('project_id'), 'user_id' => Input::post('user_id'), 'project_task_name_id' => Input::post('project_task_name_id'), 'hourly_rate' => Input::post('hourly_rate'), 'task_status' => 0, 'task_due' => Input::post('task_due'), 'project_task_description' => Input::post('project_task_description'), 'comment' => Input::post('comment'), 'priority' => Input::post('priority')));
             if ($projecttask and $projecttask->save()) {
                 Session::set_flash('success', e('Added task #' . $projecttask->id . '.'));
                 Response::redirect('user/projects/view/' . $project_id);
             } else {
                 Session::set_flash('error', e('Could not save task.'));
             }
         } else {
             \Fuel\Core\Session::set_flash('error', $val->error());
         }
     }
     $this->load_presenter($project, Model_Projecttask::forge(array('id' => 0, 'project_id' => $project->id, 'user_id' => $this->current_user->id, 'task_status' => 0, 'hourly_rate' => 456, 'task_due' => date('Y-m-d'))));
     $this->template->set_global('project_task_names', Model_Projecttaskname::find('all', array('order_by' => array(array('name', 'asc')))));
     $this->template->set_global('users', array(Model_User::find($this->current_user->id)));
     $this->template->set_global('priorities', THelper::get_priorities());
     $this->template->title = 'My Projects';
     $this->template->content = Fuel\Core\View::forge('user/projects/addtask');
 }
Example #29
0
 public function action_index()
 {
     //ログイン用のオブジェクト生成
     $auth = Auth::instance();
     $auth->logout();
     Response::redirect('members');
 }
Example #30
0
 public function before()
 {
     parent::before();
     $flag = $this->getNotOpenidAllowed();
     if ($flag) {
         return;
     }
     if (!\Session::get('wechat', false) && !\Input::get('openid', false)) {
         //获取到openid之后跳转的参数列表
         //$params = \handler\mp\UrlTool::createLinkstring(\Input::get());
         //本站域名
         $baseUrl = \Config::get('base_url');
         $url = $baseUrl . \Input::server('REQUEST_URI');
         $toUrl = urlencode($url);
         $callback = "{$baseUrl}wxapi/oauth2_callback?to_url={$toUrl}";
         $account = \Session::get('WXAccount', \Model_WXAccount::find(1));
         $url = \handler\mp\Tool::createOauthUrlForCode($account->app_id, $callback);
         \Response::redirect($url);
     } else {
         if (!\Session::get('wechat', false)) {
             $wxopenid = \Model_WechatOpenid::query()->where(['openid' => \Input::get('openid')])->get_one();
             if (!$wxopenid) {
                 \Session::set_flash('msg', ['status' => 'err', 'msg' => '未找到您的微信信息,无法确认您的身份! 系统无法为您提供服务!', 'title' => '拒绝服务']);
                 return $this->show_mesage();
             }
             \Session::set('wechat', $wxopenid->wechat);
             \Session::set('OpenID', $wxopenid);
             \Auth::force_login($wxopenid->wechat->user_id);
         } else {
             if (!\Auth::check() && \Session::get('wechat')->user_id) {
                 \Auth::force_login(\Session::get('wechat')->user_id);
             }
         }
     }
 }