public function check_login()
 {
     $throttles = in_array(ThrottlesLogin::class, class_uses_recursive(get_class($this)));
     $rules = ['password' => 'required|max:64', 'email' => 'required|max:320|email'];
     $custom_msg = ['password.required' => 'You have to fill the password form.', 'password.max' => 'Your maximum password length is 64.', 'email.required' => 'You have to fill the email form.', 'email.max' => 'Your maximum password length is 320.', 'email.email' => 'This id not a valid email.'];
     $validator = Validator::make(Input::all(), $rules, $custom_msg);
     if ($validator->fails()) {
         Session::flash('errors', $validator->messages()->all());
         return view('auth.login');
     } else {
         $password = Input::get('password');
         $email = Input::get('email');
         //$remember = (Auth::viaRemember()) ? true : false;
         if (Auth::attempt(['email' => $email, 'password' => $password])) {
             // || Auth::viaRemember()
             Auth::login(Auth::user(), true);
             Session::flash('messages', ["Successfully logged with email {$email}."]);
             Session::save();
             return view('front.qbd');
         } else {
             Session::flash('errors', ["Authentification failed. Please check your credentials"]);
             return view('auth.login');
         }
     }
 }
 /**
  * Run the application and save headers.
  * The response is up to WordPress
  *
  * @param  \Symfony\Component\HttpFoundation\Request $request
  * @return void
  */
 public function run(SymfonyRequest $request = null)
 {
     /**
      * On testing environment the WordPress helpers
      * will not have context. So we stop here.
      */
     if (defined('WELOQUENT_TEST_ENV') && WELOQUENT_TEST_ENV) {
         return;
     }
     $request = $request ?: $this['request'];
     $response = with($stack = $this->getStackedClient())->handle($request);
     // just set headers, but the content
     if (!is_admin()) {
         $response->sendHeaders();
     }
     if ('cli' !== PHP_SAPI) {
         $response::closeOutputBuffers(0, false);
     }
     /**
      * Save the session data until the application dies
      */
     add_action('wp_footer', function () use($stack, $request, $response) {
         $stack->terminate($request, $response);
         Session::save('wp_footer');
     });
 }
 private function checkCookie()
 {
     if (request()->cookie('rem_token')) {
         $user = LaravelUsers::where('remember_token', request()->cookie('rem_token'))->first();
         if ($user) {
             Session::set('username', $user->username);
             Session::set('has_access', true);
             Session::save();
         }
     }
 }
 public function verifyUser()
 {
     $data = Input::all();
     $status = Auth::attempt(['userid' => $data['userid'], 'password' => $data['password']]);
     $user = Auth::user();
     Session::save();
     return view('myaccount')->with('user', $user);
     // if($status)
     //    return view('home');
     // else
     //    echo "Wrong Credentials";
 }
Beispiel #5
0
 public function anyLogout()
 {
     $callback = Request::input('callback');
     $uid = Session::get('uid');
     Session::flush();
     Session::save();
     $domain = $this->authModel->authorized_app_domain($uid);
     $app = '';
     if (is_array($domain)) {
         $app = implode('|', $domain);
     }
     $data['app'] = $app;
     $data['landing'] = $callback;
     return view('api.sso.logout', $data);
 }
 public function postPayment(Request $request)
 {
     $quantity = $request->get('quantity');
     $payer = new Payer();
     $payer->setPaymentMethod('paypal');
     $item_1 = new Item();
     $item_1->setName(trans('store.paypal.item_name1') . env('PAYPAL_POINTS_PER_DOLLAR', 1000) . trans('store.paypal.item_name2'))->setCurrency('USD')->setQuantity($quantity)->setPrice('1');
     // unit price
     // add item to list
     $item_list = new ItemList();
     $item_list->setItems([$item_1]);
     $amount = new Amount();
     $amount->setCurrency('USD')->setTotal($quantity);
     $transaction = new Transaction();
     $transaction->setAmount($amount)->setItemList($item_list)->setDescription('Your transaction description');
     $redirect_urls = new RedirectUrls();
     $redirect_urls->setReturnUrl(URL::route('payment.status'))->setCancelUrl(URL::route('payment.status'));
     $payment = new Payment();
     $payment->setIntent('Sale')->setPayer($payer)->setRedirectUrls($redirect_urls)->setTransactions([$transaction]);
     try {
         $payment->create($this->_api_context);
     } catch (\PayPal\Exception\PPConnectionException $ex) {
         if (\Config::get('app.debug')) {
             echo 'Exception: ' . $ex->getMessage() . PHP_EOL;
             $err_data = json_decode($ex->getData(), true);
             exit;
         } else {
             die('Some error occur, sorry for inconvenient');
         }
     }
     foreach ($payment->getLinks() as $link) {
         if ($link->getRel() == 'approval_url') {
             $redirect_url = $link->getHref();
             break;
         }
     }
     // add payment ID to session
     Session::put('paypal_payment_id', $payment->getId());
     Session::save();
     if (isset($redirect_url)) {
         // redirect to paypal
         return Redirect::away($redirect_url);
     }
     return Redirect::route('original.route')->with('error', 'Unknown error occurred');
 }
Beispiel #7
0
 private function resource($uid = 0)
 {
     $data = array('uid' => $uid, 'app_id' => env('APP_ID'), 'time' => time());
     ksort($data);
     $string = '';
     foreach ($data as $key => $value) {
         $string .= "{$key}={$value}&";
     }
     $string = rtrim($string, '&');
     $string .= env('SECRET_KEY');
     $data['sign'] = md5($string);
     $url = env('SSO_RESOURCE') . '?' . http_build_query($data);
     $response = file_get_contents($url);
     $result = json_decode($response, true);
     if ($result['code'] == 0) {
         Session::put('env.resource_all', $result['data']['resource_all']);
         Session::put('env.resource_tree', $result['data']['resource_tree']);
         Session::put('env.resource_uri', $result['data']['resource_uri']);
         Session::put('env.auth', $result['data']['auth']);
         Session::save();
     } else {
         return response()->json(array('code' => 1, 'msg' => $result['msg']));
     }
 }
Beispiel #8
0
 /**
  * fromGuestToUser
  * This method is able to transfer all the guest shopping cart user to an user cart order.
  * It happens when a guest user has a shopping cart and press in checkout button.
  * @param  [object] $ordersController. Order controller object, which is passed through Authentication middleware.
  */
 public static function fromGuestToUser($ordersController)
 {
     /**
      * $cart_content contains the guest shopping cart information
      * @var [array]
      */
     $cart_content = Session::get('user.cart_content');
     //dd($cart_content, Session::get('user.cart'));
     foreach (Session::get('user.cart_content') as $product => $value) {
         $ordersController->addToOrder('cart', $product, new Request(['quantity' => $cart_content[$product] != '' ? $cart_content[$product] : 1, 'guestToUser' => 1]));
     }
     Session::forget('user.cart');
     Session::forget('user.cart_content');
     Session::save();
 }
Beispiel #9
0
 /**
  * accountVerification allows users account verification.
  *
  * @param [string] $token is the var sent to users email to validate if the account belongs to him or not.
  */
 public function accountVerification($token)
 {
     //validating if the token retrieved is valid
     $user = User::select(['id'])->where('confirmation_code', 'LIKE', $token)->first();
     if ($user) {
         $name = $user->name . ' ' . $user->last_name;
         Session::put('message', str_replace('[name]', $name, trans('user.account_verified_ok_message')));
     } else {
         Session::put('messageClass', 'alert alert-danger');
         Session::put('message', trans('user.account_verified_error_message'));
     }
     Session::save();
     return redirect('/');
 }
 public function doLogin(Request $request)
 {
     if (!$request->has('email')) {
         echo '{"success":false,"msg":"Please fill in your Email!"}';
         exit;
     }
     $email = strtolower($request->input('email'));
     if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
         echo '{"success":false,"msg":"Your Email address format is incorrect! Please try again!"}';
         exit;
     }
     if (!$request->has('password')) {
         echo '{"success":false,"msg":"Please enter your Password!"}';
         exit;
     } else {
         $password = md5($request->input('password'));
     }
     $row = DB::select("select * from members where email = '{$email}' and password = '******'");
     if (sizeof($row) == 1) {
         if ($row[0]->status == "Active") {
             $fName = explode(" ", $row[0]->name)[0];
             $request->session()->put('memberID', $row[0]->id);
             $request->session()->put('memberName', $fName);
             $request->session()->put('member', $row[0]->email);
             $request->session()->put('memberCardID', $row[0]->memberCardID);
             Session::save();
             $response = new Response();
             $shoppingCartItemsFromCookie = json_decode($request->cookie('shoppingCart'), true);
             if ($shoppingCartItemsFromCookie != null) {
                 $shoppingCartItemsFromDB = DB::select("select * from shopping_cart where member_id = '{$email}'");
                 $shoppingCartItemsFromDB = json_decode($shoppingCartItemsFromDB[0]->shopping_cart, true);
                 foreach ($shoppingCartItemsFromCookie as $product_id => $amount) {
                     if (array_key_exists($product_id, $shoppingCartItemsFromDB)) {
                         $maxStock = DB::select("select * from products where product_id = '{$product_id}'");
                         $newAmount = $shoppingCartItemsFromDB[$product_id] + $amount;
                         if ($newAmount > $maxStock[0]->stock) {
                             $newAmount = $maxStock[0]->stock;
                         }
                         $shoppingCartItemsFromDB[$product_id] = $newAmount;
                     } else {
                         $shoppingCartItemsFromDB[$product_id] = $amount;
                     }
                     unset($shoppingCartItemsFromCookie[$product_id]);
                 }
                 $shoppingCartItemsFromDB = json_encode($shoppingCartItemsFromDB);
                 DB::table('shopping_cart')->where('member_id', $email)->update(['shopping_cart' => $shoppingCartItemsFromDB]);
                 return response('{"success":true}')->withCookie(cookie('shoppingCart', json_encode($shoppingCartItemsFromCookie)));
             } else {
                 return '{"success":true}';
             }
         } elseif ($row[0]->status == "Disable") {
             echo '{"success":false,"msg":"Your account has been disabled, Please contact the administrator!"}';
             exit;
         } else {
             echo '{"success":false,"msg":"Your account has not been activated, Please check your email and activate your account."}';
             exit;
         }
     } else {
         echo '{"success":false,"msg":"Your email or password is incorrect, please try again!"}';
         exit;
     }
 }
 public function getRegCode(Request $request)
 {
     if (Session::has('mobile_code')) {
         if (time() - Session::get('mobile_code_time') < 30) {
             return 999;
         }
     }
     /*  $yunpianSms = new YunPianSms();
             $helper = new Helper();
             $random_code = $helper->mt_rand_str(6, '0123456789');
             $response = $yunpianSms->sendMsg($mobile, '【最惠购】您的验证码是' . $random_code . '。有效期为5分钟,请尽快验证');
     
             */
     $mobile = $request->get('mobile');
     $apikey = "b2e2c4a661a0cf7e1d80f7bb167d142f";
     //请用自己的apikey代替
     $helper = new Helper();
     $random_code = $helper->mt_rand_str(6, '0123456789');
     $tpl_value = "#company#=最惠购&#code#=" . $random_code;
     // $text='【最惠购】您的验证码是' . $random_code . '。有效期为5分钟,请尽快验证';
     // Session::flash('regcode', $random_code);
     $tpl_id = 1;
     $response = json_decode($this->tpl_send_sms($apikey, $tpl_id, $tpl_value, $mobile))->data->code;
     //Log::error('Something is really going wrong.');
     //  $result = json_decode($response)->data->code;
     //   if ($result == 0)
     //   {
     Session::put('mobile_code', $random_code);
     Session::put('mobile_code_time', time());
     //   }
     Session::save();
     return $response;
 }
Beispiel #12
0
 /**
  * Set payment data.
  *
  * @param  array  $parameters
  *
  * @return void
  */
 protected function setPaymentData(array $parameters)
 {
     Session::put('payment', $parameters);
     Session::save();
 }
Beispiel #13
0
 public function resetHaystack()
 {
     Session::forget('suggest-listed');
     Session::save();
 }
Beispiel #14
0
 /**
  * Save the data, if necessary.    This would be a no-op when using the
  * $_SESSION implementation, but could be used for saving to file or
  * database as an action instead of on every set.
  *
  * @return null
  */
 public function save()
 {
     Session::save();
 }
 public function setSidAttribute($value)
 {
     $this->attributes['sid'] = $value;
     Session::put('visitor_log_sid', $value);
     Session::save();
 }
 /**
  * Increase the product counters.
  *
  * @param [object] $product is the object which contain the product evaluated
  * @param [array]  $data    is the method config that has all the info requeried (table field, amount to be added)
  * @param [string] $wrapper is the products session array position key.
  */
 public static function setCounters($product = null, $data = [], $wrapper = '')
 {
     if (\Auth::user() && $product != '' && count($data) > 0) {
         $_array = Session::get('products.' . $wrapper);
         //products already evaluated
         if (count($_array) == 0 || !in_array($product->id, $_array)) {
             //looked up to make sure the product is not in $wrapper array already
             foreach ($data as $key => $value) {
                 if ($key != '' && $data[$key] != '') {
                     $product->{$key} = $product->{$key} + intval($data[$key]);
                     $product->save();
                 }
             }
             Session::push('products.' . $wrapper, $product->id);
             //build product list to not increase a product more than one time per day
             Session::save();
         }
     }
 }
Beispiel #17
0
 function setOAuthSession($token, $secret, $expires = null)
 {
     Session::put('oauth', ['token' => $token, 'token_secret' => $secret, 'expires' => time() + $expires]);
     Session::save();
 }
 public function generateRandomNumbers()
 {
     return Session::set('test', 'test');
     Session::save('numbers', $numbers);
 }