checkout, register, payment,
checkout correction, register wizard, payment packege,
This commit is contained in:
parent
6e3adac4d7
commit
446bc4561b
48 changed files with 2580 additions and 1493 deletions
83
app/Http/Middleware/Authenticate.php
Normal file
83
app/Http/Middleware/Authenticate.php
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Auth\AuthenticationException;
|
||||
use Illuminate\Contracts\Auth\Factory as Auth;
|
||||
|
||||
class Authenticate
|
||||
{
|
||||
/**
|
||||
* The authentication factory instance.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Auth\Factory
|
||||
*/
|
||||
protected $auth;
|
||||
|
||||
/**
|
||||
* Create a new middleware instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Factory $auth
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Auth $auth)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @param string[] ...$guards
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Illuminate\Auth\AuthenticationException
|
||||
*/
|
||||
public function handle($request, Closure $next, ...$guards)
|
||||
{
|
||||
|
||||
$this->authenticate($guards);
|
||||
|
||||
//is blocked
|
||||
if(in_array('user', $guards) && $this->auth->user()->blocked == 1){
|
||||
return redirect(route('user_blocked'));
|
||||
}
|
||||
|
||||
//is wizard
|
||||
if(in_array('user', $guards) && $this->auth->user()->wizard < 5){
|
||||
return redirect(route('wizard'));
|
||||
}
|
||||
//can use wizard < 10 to repay
|
||||
if(in_array('user', $guards) && $this->auth->user()->wizard < 10){
|
||||
//return redirect(route('wizard'));
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the user is logged in to any of the given guards.
|
||||
*
|
||||
* @param array $guards
|
||||
* @return void
|
||||
*
|
||||
* @throws \Illuminate\Auth\AuthenticationException
|
||||
*/
|
||||
protected function authenticate(array $guards)
|
||||
{
|
||||
if (empty($guards)) {
|
||||
return $this->auth->authenticate();
|
||||
}
|
||||
|
||||
foreach ($guards as $guard) {
|
||||
if ($this->auth->guard($guard)->check()) {
|
||||
return $this->auth->shouldUse($guard);
|
||||
}
|
||||
}
|
||||
|
||||
throw new AuthenticationException('Unauthenticated.', $guards);
|
||||
}
|
||||
}
|
||||
|
|
@ -21,7 +21,6 @@ class Checkout
|
|||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
|
||||
if($identifier = ShoppingInstance::where('identifier', $request->route('identifier'))->first()){
|
||||
//user shop
|
||||
$user_shop = $identifier->user_shop;
|
||||
|
|
@ -29,7 +28,12 @@ class Checkout
|
|||
Util::setPostRoute('user.');
|
||||
\Session::put('user_shop', $user_shop);
|
||||
\Session::put('isCheckout', true);
|
||||
|
||||
if($identifier->auth_user_id){
|
||||
\Session::put('auth_user', $identifier->auth_user);
|
||||
}
|
||||
}
|
||||
Yard::instance('shopping')->destroy();
|
||||
//restore yard
|
||||
Yard::instance('shopping')->restore($request->route('identifier'));
|
||||
Yard::instance('shopping')->setShippingCountryWithPrice($identifier->country_id);
|
||||
|
|
@ -47,4 +51,4 @@ class Checkout
|
|||
return redirect(config('app.url'));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue