Example #1
0
 public function sign(Request $request, $id)
 {
     $delivery = Delivery::find($id);
     if (!$delivery || $delivery->state == 0) {
         return Response::json("Error", 400);
     } else {
         //Okay,  let's check if the  the current logged agent
         $userId = Authorizer::getResourceOwnerId();
         $agent = Agent::where('user_id', $userId)->first();
         if (!$agent) {
             return Response::json("Error", 400);
         }
         if ($delivery->agent_id != $agent->id) {
             return Response::json("Error", 403);
         }
         $file = $request->file('signature');
         if ($file !== null) {
             if ($file->isValid()) {
                 $file->move(public_path() . "/uploads", $id . "_signature.png");
                 return Response::json("OK", 200);
             }
         }
     }
     return Response::json("Error", 400);
 }
Example #2
0
 /**
  * Ensure the current authentication has access to the requested scope.
  *
  * @param string $scope
  *
  * @return bool
  */
 public function checkScope($scope)
 {
     if (isset($this->scopes[$scope])) {
         return $this->scopes[$scope];
     }
     if (!empty($this->scopes['*'])) {
         return true;
     }
     if (!$this->check()) {
         return false;
     }
     if ('user' == $this->type) {
         $this->scopes[$scope] = Authorizer::hasScope($scope);
     } else {
         $client = $this->client();
         $this->scopes[$scope] = in_array($scope, $client->scopes());
     }
     if (!$this->scopes[$scope] && '*' != $scope) {
         $this->scopes[$scope] = $this->checkScope('*');
     }
     return $this->scopes[$scope];
 }
Example #3
0
 public function passwordChange()
 {
     $oldPassword = Input::get('old_password');
     $newPassword = Input::get('new_password');
     if (!empty($oldPassword) && !empty($newPassword)) {
         $userId = Authorizer::getResourceOwnerId();
         $user = User::find($userId);
         if (!empty($user)) {
             if (\Auth::validate(['email' => $user->email, 'password' => $oldPassword])) {
                 $user->password = \Hash::make($newPassword);
                 $user->save();
                 return Response::json("OK", 200);
             }
         }
     }
     return Response::json("Error", 400);
 }