Exemplo n.º 1
0
 public function handle($request, Closure $next)
 {
     $authtoken = \Input::header('authtoken');
     $now = Carbon::now();
     $hasActiveSession = $this->sessionRepo->hasActiveSession($authtoken, $now);
     if (!$hasActiveSession) {
         return response(NULL, 401);
     }
     return $next($request);
 }
 public function trialPayResponse()
 {
     //dd(Input::all());
     $message_signature = Input::header('TrialPay-HMAC-MD5');
     // Recalculate the signature locally
     $key = Config::get('trial_pay.notification_key');
     $request = Request::instance();
     $HTTP_RAW_POST_DATA = $request->getContent();
     if (Input::get('user_id') == "sample-sid") {
         return 1;
     }
     if (Input::method() == 'POST') {
         // the following is for POST notification
         if (empty($HTTP_RAW_POST_DATA)) {
             $recalculated_message_signature = hash_hmac('md5', file_get_contents('php://input'), $key);
         } else {
             $recalculated_message_signature = hash_hmac('md5', $HTTP_RAW_POST_DATA, $key);
         }
     } else {
         // the following is for GET notification
         $recalculated_message_signature = hash_hmac('md5', $_SERVER['QUERY_STRING'], $key);
     }
     \Log::error("**********Message Signature " . $message_signature);
     \Log::error("**********Calculated Signature " . $recalculated_message_signature);
     if ($message_signature == $recalculated_message_signature) {
         \Log::error("**********Signature Match Successful");
         $user_id = Input::get('user_id');
         //$user_id = 1;
         \Log::error("**********Finding User ID " . $user_id);
         //user exists
         $user = User::where('id', $user_id)->first();
         if (sizeof($user) > 0) {
             \Log::error("**********User Found " . $user->name);
             //exists , increment coins and cash
             $user->coins = $user->coins + Input::get('reward_amount');
             $user->cash = $user->cash + Input::get('reward');
             //Log the request
             $trial_pay_request = new TrialPayResponse();
             $trial_pay_request->user_id = Input::get('user_id');
             $trial_pay_request->email = Input::get('email');
             $trial_pay_request->country = Input::get('country');
             $trial_pay_request->zipcode = Input::get('zipcode');
             $trial_pay_request->reward_amount = Input::get('reward_amount');
             $trial_pay_request->oid = Input::get('oid');
             $trial_pay_request->revenue = Input::get('revenue');
             $trial_pay_request->trans_type = Input::get('trans_type');
             $trial_pay_request->offer_category = Input::get('offer_category');
             $trial_pay_request->order_date = Input::get('order_date');
             $trial_pay_request->product_id = Input::get('product_id');
             $trial_pay_request->traffic_source = Input::get('traffic_source');
             $trial_pay_request->product_price = Input::get('product_price');
             $trial_pay_request->save();
             $cgs = new \Cashout\Helpers\CGS();
             $cgs->sendReferralCoins(Input::get('user_id'), Input::get('reward_amount'), $trial_pay_request->id);
             return 1;
         } else {
             \Log::error("**********User Not Found ");
             //do nothing
             \Log::error("**********UNAUTHENTICATED SID-REQUEST FOUND");
         }
         \Log::error(Input::all());
     } else {
         \Log::error('Message not Authentic');
     }
     //check if user with that sid exists
     return 0;
 }
Exemplo n.º 3
0
 |
*/
Route::filter('auth', function () {
    if (Auth::guest()) {
        if (Request::ajax()) {
            return Response::make('Unauthorized', 401);
        } else {
            return Redirect::guest('login');
        }
    }
});
Route::filter('auth.basic', function () {
    return Auth::basic("username");
});
Route::filter('checktoken', function () {
    $datos = Input::header();
    $token = $datos['auth-token'];
    $user = User::where('authentication_token', '=', $token)->get();
    if ($user->count() == 0) {
        return Response::make('Unauthorized', 401);
    }
});
/*
 |--------------------------------------------------------------------------
 | Guest Filter
 |--------------------------------------------------------------------------
 |
 | The "guest" filter is the counterpart of the authentication filters as
 | it simply checks that the current user is not logged in. A redirect
 | response will be issued if they are, which you may freely change.
 |