当前位置: 首页>>代码示例>>PHP>>正文


PHP Guard::getUser方法代码示例

本文整理汇总了PHP中Illuminate\Contracts\Auth\Guard::getUser方法的典型用法代码示例。如果您正苦于以下问题:PHP Guard::getUser方法的具体用法?PHP Guard::getUser怎么用?PHP Guard::getUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Contracts\Auth\Guard的用法示例。


在下文中一共展示了Guard::getUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!$this->auth->getUser()->can(Route::currentRouteAction())) {
         return abort(403);
     }
     return $next($request);
 }
开发者ID:kaainet,项目名称:holidaypirates-task,代码行数:14,代码来源:Access.php

示例2: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $user = $this->auth->getUser();
     $confirmed = $user['confirmed'];
     if (isset($confirmed) && $confirmed == "0") {
         // If the user has not had an activation token set
         $confirmation_code = $user->confirmation_code;
         if (empty($confirmation_code)) {
             // generate a confirmation code
             $key = \Config::get('app.key');
             do {
                 $confirmation_code = hash_hmac('sha256', str_random(40), $key);
             } while (User::where('confirmation_code', $confirmation_code)->exists());
             $user->confirmation_code = $confirmation_code;
             $user->save();
             \Mail::send('emails.activate', ['token' => $confirmation_code, 'name' => $user->name], function ($message) use($user) {
                 $message->from($user->email);
                 $message->to("hpapms@gmail.com", "Admin")->subject('Account Verification');
             });
         }
         \Session::put('alertMessage', 'Your email needs confirmation from admin!');
         return redirect()->guest('auth/logout');
     }
     return $next($request);
 }
开发者ID:hpapmssytem,项目名称:apms,代码行数:32,代码来源:UserConfirmed.php

示例3: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($this->auth->guest() || !$this->auth->getUser()->is_admin) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             return redirect()->guest(route('admin.login'));
         }
     }
     return $next($request);
 }
开发者ID:ThunderID,项目名称:capcus.v2,代码行数:18,代码来源:AuthenticateAdmin.php

示例4: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($this->auth->guest() || $this->auth->getUser()->is_admin <= 1) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             return redirect()->back()->withErrors('Unauthorized Access');
         }
     }
     return $next($request);
 }
开发者ID:ThunderID,项目名称:capcus.v2,代码行数:18,代码来源:AuthenticateSuperadmin.php

示例5: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($this->auth->guest()) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             return redirect()->guest('auth/login');
         }
     }
     App::setLocale($this->auth->getUser()->language_code);
     return $next($request);
 }
开发者ID:kitbs,项目名称:vinfo,代码行数:19,代码来源:Authenticate.php

示例6: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($this->auth->guest()) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             return redirect()->guest('auth/login');
         }
     }
     if ($this->auth->getUser()->role_id !== 1) {
         return redirect()->guest('auth/login');
     }
     return $next($request);
 }
开发者ID:avil13,项目名称:lab.friends,代码行数:21,代码来源:Administrator.php

示例7: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id, UpdateAccountRequest $request, Guard $auth, AccountRepository $account_respository, APIControllerHelper $helper)
 {
     $user = $auth->getUser();
     if (!$user) {
         throw new Exception("User not found", 1);
     }
     // get non null attributes only
     $attributes = $request->only(array_keys($request->rules()));
     $non_null_attributes = [];
     foreach ($attributes as $k => $v) {
         if ($v !== null) {
             $non_null_attributes[$k] = $v;
         }
     }
     if (!$non_null_attributes) {
         return $helper->buildJSONResponse(['message' => 'nothing to update'], 400);
     }
     // update
     try {
         return $helper->update($account_respository, $id, $non_null_attributes, $user);
     } catch (Exception $e) {
         if ($e->getCode() >= 400 and $e->getCode() < 500) {
             throw new HttpResponseException(new JsonResponse(['message' => $e->getMessage()], 400));
         }
         throw $e;
     }
 }
开发者ID:CryptArc,项目名称:xchain,代码行数:33,代码来源:AccountController.php

示例8: destroy

 /**
  * Handle delete account request
  *
  * @return \Illuminate\Http\Response
  */
 public function destroy()
 {
     $user = $this->auth->getUser();
     $this->repo->destroy($user->id);
     event('UserDeleted', [$user]);
     return $this->respondDeleteSuccess();
 }
开发者ID:valdinei,项目名称:rest,代码行数:12,代码来源:RegisterController.php

示例9: transfer

 public function transfer($address_uuid, Guard $auth, AccountTransferRequest $request, APIControllerHelper $helper, PaymentAddressRepository $payment_address_repository, APICallRepository $api_call_repository)
 {
     $user = $auth->getUser();
     if (!$user) {
         throw new Exception("User not found", 1);
     }
     $payment_address = $helper->requireResourceOwnedByUser($address_uuid, $user, $payment_address_repository);
     $params = $helper->getAttributesFromRequest($request);
     $api_call = $api_call_repository->create(['user_id' => $user['id'], 'details' => ['method' => 'api/v1/accounts/transfer/' . $address_uuid, 'args' => $params]]);
     try {
         if (isset($params['close']) and $params['close']) {
             AccountHandler::close($payment_address, $params['from'], $params['to'], $api_call);
         } else {
             if (isset($params['quantity']) and isset($params['asset'])) {
                 AccountHandler::transfer($payment_address, $params['from'], $params['to'], $params['quantity'], $params['asset'], isset($params['txid']) ? $params['txid'] : null, $api_call);
             } else {
                 // transfer all
                 AccountHandler::transferAllByTIXD($payment_address, $params['from'], $params['to'], $params['txid'], $api_call);
             }
         }
         // done
         return $helper->buildJSONResponse([], 204);
     } catch (AccountException $e) {
         return $helper->buildJSONResponse(['message' => $e->getMessage(), 'errorName' => $e->getErrorName()], $e->getStatusCode());
     } catch (HttpException $e) {
         return $helper->buildJSONResponse(['message' => $e->getMessage()], $e->getStatusCode());
     }
 }
开发者ID:CryptArc,项目名称:xchain,代码行数:28,代码来源:AccountBalancesController.php

示例10: primeAddress

 /**
  * Prime the address with UTXOs of a certain size
  *   only if needed
  * 
  *
  * @return Response
  */
 public function primeAddress($address_uuid, Guard $auth, Request $request, APIControllerHelper $helper, PaymentAddressRepository $payment_address_repository, TXORepository $txo_repository, TXOChooser $txo_chooser, PaymentAddressSender $payment_address_sender)
 {
     try {
         $user = $auth->getUser();
         if (!$user) {
             throw new Exception("User not found", 1);
         }
         $payment_address = $helper->requireResourceOwnedByUser($address_uuid, $user, $payment_address_repository);
         $size = floatval($request->input('size'));
         if ($size <= 0) {
             throw new Exception("Invalid size", 400);
         }
         $size_satoshis = CurrencyUtil::valueToSatoshis($size);
         $desired_prime_count = floatval($request->input('count'));
         if ($desired_prime_count <= 0) {
             throw new Exception("Invalid count", 400);
         }
         $fee = $request->input('fee');
         if ($fee !== null) {
             $fee = floatval($fee);
             if ($fee <= 0) {
                 throw new Exception("Invalid fee", 400);
             }
         }
         // get the UTXOs
         //   [TXO::UNCONFIRMED, TXO::CONFIRMED]
         $txos = $this->filterGreenOrConfirmedUTXOs($txo_repository->findByPaymentAddress($payment_address, null, true));
         // count the number that match the size
         $current_primed_count = 0;
         foreach ($txos as $txo) {
             if ($txo['amount'] == $size_satoshis) {
                 ++$current_primed_count;
             }
         }
         $txid = null;
         $new_primed_count = $current_primed_count;
         if ($desired_prime_count > $current_primed_count) {
             // create a new priming transaction...
             $desired_new_primes_count_to_create = $desired_prime_count - $current_primed_count;
             $actual_new_primes_count_to_create = $this->findMaximumNewPrimeCountTXOs($txo_chooser, $payment_address, $desired_new_primes_count_to_create, $size, $fee);
             if ($actual_new_primes_count_to_create > 0) {
                 $txid = $this->sendPrimingTransaction($payment_address_sender, $payment_address, $size, $actual_new_primes_count_to_create, $fee);
                 $new_primed_count = $current_primed_count + $actual_new_primes_count_to_create;
             }
         }
         $output = ['oldPrimedCount' => $current_primed_count, 'newPrimedCount' => $new_primed_count, 'txid' => $txid, 'primed' => $txid ? true : false];
         return $helper->buildJSONResponse($output);
     } catch (Exception $e) {
         if ($e->getCode() >= 400 and $e->getCode() < 500) {
             throw new HttpResponseException(new JsonResponse(['errors' => [$e->getMessage()]], 400));
         }
         throw $e;
     }
 }
开发者ID:CryptArc,项目名称:xchain,代码行数:61,代码来源:PrimeController.php

示例11: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $user = $this->auth->getUser();
     $confirmed = $user->confirmed;
     if (isset($confirmed) && $confirmed == "0") {
         // If the user has not had an activation token set
         $confirmation_code = $user->confirmation_code;
         if (empty($confirmation_code)) {
             // generate a confirmation code
             $key = \Config::get('app.key');
             $confirmation_code = hash_hmac('sha256', str_random(40), $key);
             $user->confirmation_code = $confirmation_code;
             $user->save();
             \Mail::send('emails.activate', ['token' => $confirmation_code, 'name' => $user->name], function ($message) use($user) {
                 $message->to($user->getEmailForPasswordReset(), $user->name)->subject('Activate your Notify account');
             });
         }
         return redirect()->guest('/activate');
     }
     return $next($request);
 }
开发者ID:gayankalhara,项目名称:planmyevent,代码行数:28,代码来源:UserConfirmed.php

示例12: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(APIControllerHelper $helper, CreateMonitorRequest $request, MonitoredAddressRepository $address_respository, Guard $auth)
 {
     $user = $auth->getUser();
     if (!$user) {
         throw new Exception("User not found", 1);
     }
     $attributes = $request->only(array_keys($request->rules()));
     $attributes['user_id'] = $user['id'];
     $address = $address_respository->create($attributes);
     EventLog::log('monitor.created', json_decode(json_encode($address)));
     return $helper->transformResourceForOutput($address);
 }
开发者ID:CryptArc,项目名称:xchain,代码行数:17,代码来源:MonitorController.php

示例13: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(APIControllerHelper $helper, CreatePaymentAddressRequest $request, PaymentAddressRepository $payment_address_respository, Guard $auth)
 {
     $user = $auth->getUser();
     if (!$user) {
         throw new Exception("User not found", 1);
     }
     $attributes = $request->only(array_keys($request->rules()));
     $attributes['user_id'] = $user['id'];
     $address = $payment_address_respository->create($attributes);
     EventLog::log('paymentAddress.created', $address->toArray());
     // create a default account
     AccountHandler::createDefaultAccount($address);
     return $helper->transformResourceForOutput($address);
 }
开发者ID:CryptArc,项目名称:xchain,代码行数:19,代码来源:PaymentAddressController.php

示例14: postLogin

 /**
  * Handle a login request to the application.
  *
  * @param AuthRequest $request
  * @return \Illuminate\Http\Response
  */
 public function postLogin(AuthRequest $request)
 {
     $throttles = in_array(ThrottlesLogins::class, class_uses_recursive(get_class($this)));
     if ($throttles && $this->hasTooManyLoginAttempts($request)) {
         return $this->respondThrottled($request);
     }
     if (!$this->auth->once($request->only('email', 'password'))) {
         if ($throttles) {
             $this->incrementLoginAttempts($request);
         }
         return $this->respondLoginFail($request);
     }
     $user = $this->auth->getUser();
     if (!$user->activated) {
         $this->auth->logout();
         return $this->respondNotActivated($request, $user->activation_code);
     }
     $this->auth->loginUsingId($user->id, $request->has('remember'));
     if ($throttles) {
         $this->clearLoginAttempts($request);
     }
     event('UserHasLoggedIn', [$this->auth->user()]);
     return $this->respondLoginSuccess($request, $user);
 }
开发者ID:valdinei,项目名称:rest,代码行数:30,代码来源:SessionController.php

示例15: handle

 /**
  * @param UserRepository $userRepository
  * @param ShiftRepository $shiftRepository
  * @param Shift $shift
  * @param Guard $auth
  * @return Shift
  */
 public function handle(UserRepository $userRepository, ShiftRepository $shiftRepository, Shift $shift, Guard $auth)
 {
     $shift->setBreak($this->break);
     $shift->setStartTime($this->start_time);
     $shift->setEndTime($this->end_time);
     if ($this->employee_id) {
         $shift->setEmployee($userRepository->getOneById($this->employee_id));
     }
     if ($this->manager_id) {
         $shift->setManager($userRepository->getOneById($this->manager_id));
     } else {
         $shift->setManager($auth->getUser());
     }
     $shiftRepository->store($shift);
     $shiftRepository->update($shift);
     return $shift;
 }
开发者ID:sctape,项目名称:scheduler,代码行数:24,代码来源:CreateShift.php


注:本文中的Illuminate\Contracts\Auth\Guard::getUser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。