作者:jaysongy
项目:dme
public function store(array $data)
{
try {
$userId = Authorizer::getResourceOwnerId();
$this->user = $this->repository->find($userId);
$data['cliente_id'] = $this->user->cliente_id;
//$this->validator->with($data)->passesOrFail();
//Verificando se email existeformlogin
$usuario = $this->repository->findWhere(['cliente_id' => $data['cliente_id'], 'email' => $data['email']]);
if ($usuario->count()) {
return ['warning' => true, 'message' => 'Email já cadastrado!'];
}
$data['token_senha'] = str_random(60);
$this->repository->create($data);
$data['link'] = 'www.teste.proload.com.br/#/acesso/' . $data['token_senha'];
Mail::send('email.bemvindo', ['dado' => $data], function ($m) use($data) {
$m->to($data['email'], $data['name'])->subject('Bem vindo ao ProDmed');
});
return ['success' => true, 'message' => 'Usuário cadastrado com sucesso!'];
} catch (ValidatorException $e) {
return ['error' => true, 'message' => $e->getMessageBag()];
} catch (QueryException $e) {
return ['error' => true, 'message' => $e->getMessage()];
}
}
作者:phelipp
项目:multites
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
#Precisa desse validate para funcionar
$validado = Authorizer::validateAccessToken();
/*dd(Authorizer::validateAccessToken(),
Authorizer::getResourceOwnerId(),
Authorizer::getResourceOwnerType(),
Authorizer::getAccessToken()->getId(),
Authorizer::getAccessToken());*/
/*$token = Authorizer::getAccessToken()->getId();
$id_cliente = Authorizer::getResourceOwnerId();
$token_db = DB::table('oauth_access_tokens')
->where('id', $token)
->where('grant_type', 'cliente')->first();
#dd($token_db);
if($validado && $token_db){
}*/
$checker = Authorizer::getChecker();
$accessToken = $checker->getAccessToken();
#dd($checker);
#dd($accessToken);
$accessTokenEntity = DB::table('oauth_access_tokens')->where('id', $accessToken)->first();
#dd($accessTokenEntity);
$grantType = $accessTokenEntity->grant_type ? $accessTokenEntity->grant_type : null;
#dd($grantType);
if ($grantType != 'cliente') {
abort(403, 'Access forbidden');
}
return $next($request);
}
作者:douglasresendemacie
项目:laravel_deliver
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
$deliverymanId = Authorizer::getResourceOwnerId();
if ($order = $this->orderService->updateStatus($id, $deliverymanId, $request->get('status'))) {
return $order;
}
abort(400, 'Pedido não encontrado');
}
作者:heneme
项目:codeprojec
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$project_id = $request->project;
if ($this->repository->isOwner($project_id, Authorizer::getResourceOwnerId()) == false) {
return ['error' => 'Access forbidden'];
}
return $next($request);
}
作者:ssistema
项目:deliver
public function store(CheckoutRequest $request)
{
$data = $request->all();
$client = $this->userRepository->find(Authorizer::getResourceOwnerId())->client->id;
$data['client_id'] = $client;
$order = $this->orderService->create($data);
return $this->orderRepository->skipPresenter(false)->with($this->with)->find($order->id);
}
作者:phelipp
项目:CodeProjec
public function index()
{
#$rtrn = $this->user_repository->skipPresenter()->find(Authorizer::getResourceOwnerId())->projects()->with(['client', 'tasks', 'notes', 'members', 'owner'])->get();
$rtrn = $this->repository->findWithOwnerAndMember(Authorizer::getResourceOwnerId());
#$rtrn = $this->user_repository->find(Authorizer::getResourceOwnerId())->projects()->with(['client', 'tasks', 'notes', 'members', 'owner'])->get();
#return $this->user_repository->find(Authorizer::getResourceOwnerId())->projects()->with(['client', 'tasks', 'notes', 'members'])->get();
return $rtrn;
}
作者:adrianodri
项目:codedelivery.de
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next, $role)
{
$user = $this->userRepository->skipPresenter()->find(Authorizer::getResourceOwnerId());
if ($user->role != $role) {
abort(403, 'Access forbidden');
}
return $next($request);
}
作者:kidshenlon
项目:comic-cloud-lume
public function createToken(Request $request)
{
$json = $request->json()->all();
$request = new Request();
$request->request->replace($json);
Authorizer::setRequest($request);
return $this->respond(Authorizer::issueAccessToken());
}
作者:netoud
项目:laravel-angularj
public function all($id = null, $limit = 6)
{
$this->setPresenter();
if (!is_null($id)) {
return $this->repository->findWhere(['project_id' => $id]);
}
return $this->repository->recentTasks(Authorizer::getResourceOwnerId(), $limit);
}
作者:brunowernec
项目:CodeProjec
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$id = $request->id;
if (!$this->repository->isOwner($id, Authorizer::getResourceOwnerId())) {
return response()->json(['error' => true, 'message' => ['owner' => 'You are not an authorized user in this project']], 403);
}
return $next($request);
}
作者:silviobarrett
项目:codeprojec
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$userId = Authorizer::getResourceOwnerId();
$cursoId = $request->curso;
if ($this->repository->isOwner($cursoId, $userId) == false) {
return ['error' => 'Access forbidden'];
}
return $next($request);
}
作者:jaysongy
项目:dme
public function __construct(EmpresaRepository $repository, EmpresaValidator $validator, PrefeituraGoiania $prefeitura, UserRepository $userRepository)
{
$this->repository = $repository;
$this->validator = $validator;
$this->prefeitura = $prefeitura;
$this->userRepository = $userRepository;
$userId = Authorizer::getResourceOwnerId();
$this->user = $this->userRepository->find($userId);
}
作者:douglasresendemacie
项目:laravel_deliver
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next, ...$params)
{
$id = Authorizer::getResourceOwnerId();
$user = $this->userRepository->find($id);
if (!in_array($user->role, $params)) {
abort(403, 'Access Forbidden');
}
return $next($request);
}
作者:tiagocardoso
项目:laravel-codeeducatio
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$userId = Authorizer::getResourceOwnerId();
$projectId = $request->project;
if ($this->repository->isOwner($projectId, $userId) == false) {
return ['success' => false, 'userId' => 'Forbidden'];
}
return $next($request);
}
作者:rpc191
项目:LaravelDeliver
public function store(Request $request)
{
$id = Authorizer::getResourceOwnerId();
$dados = $request->all();
$cliente = $this->userRepository->find($id)->cliente->id;
$dados['cliente_id'] = $cliente;
$pedido = $this->pedidoService->criar($dados);
return $this->repository->with('items')->find($pedido->id);
}
作者:JhonnyHRoch
项目:linc
/**
* @param VendasRepository $repository
* @param VendasService $service
*/
public function __construct(VendasRepository $repository, VendasService $service, RevendedoresRepository $revendedoresRepository)
{
$this->repository = $repository;
$this->service = $service;
$this->revendedoresRepository = $revendedoresRepository;
$userId = Authorizer::getResourceOwnerId();
$revendedor = $this->revendedoresRepository->findWhere(['id_usuario' => $userId]);
$this->id_revendedor = $revendedor[0]['id'];
}
作者:cristianvuol
项目:cursoLaravelAngua
public function checkPermissions($projectId)
{
$owner = $this->project->find($projectId)->owner_id;
$userId = Authorizer::getResourceOwnerId();
if ($owner != $userId and !$this->hasMember($projectId)) {
throw new \Exception('Access Denied');
}
return true;
}
作者:AllanKlau
项目:CodeDeliver
public function store(CheckoutRequest $request)
{
$id = Authorizer::getResourceOwnerID();
$data = $request->all();
$clientId = $this->userRepository->find($id)->client->id;
$data['client_id'] = $clientId;
$order = $this->orderService->create($data);
return $this->repository->with($this->with)->find($order->id);
}
作者:pdayvso
项目:laravel-codedelirev
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$data = $request->all();
$clientId = $this->userRepository->find(Authorizer::getResourceOwnerId())->client->id;
$data['client_id'] = $clientId;
$order = $this->orderService->create($data);
$order = $this->orderRepository->with('items')->find($order->id);
return $order;
}
作者:AllanKlau
项目:CodeDeliver
public function handle($request, Closure $next, $role)
{
$id = Authorizer::getResourceOwnerID();
$user = $this->userRepository->find($id);
if ($user->role != $role) {
abort('403', 'Access Forbidden');
}
return $next($request);
}