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); }
/** * Get the userID for the current request (access_token or Authorization header). * * @return int */ public function userId() { if (isset($this->user_id)) { return $this->user_id ? $this->user_id : null; } $this->check(); $this->user_id = false; if ('user' == $this->type) { if ($user_id = Authorizer::getResourceOwnerId()) { return $this->user_id = $user_id; } } return null; }
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); }