Commit f39415e0 authored by Viral Solani's avatar Viral Solani

WIP

parent bcfbaa1e
...@@ -3,26 +3,59 @@ ...@@ -3,26 +3,59 @@
namespace App\Http\Controllers\Api\V1; namespace App\Http\Controllers\Api\V1;
use App\Repositories\Frontend\Access\User\UserRepository; use App\Repositories\Frontend\Access\User\UserRepository;
use Tymon\JWTAuth\JWTAuth;
use Illuminate\Support\Facades\Password;
use Illuminate\Foundation\Auth\ResetsPasswords; use Illuminate\Foundation\Auth\ResetsPasswords;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Validator;
/** /**
* Class ResetPasswordController. * Class ResetPasswordController.
*/ */
class ResetPasswordController extends APIController class ResetPasswordController extends APIController
{ {
/**
* User Repository
* @var obj
*/
protected $user;
/**
* Rest Password Constructor
*
* @param UserRepository $user
*/
public function __construct(UserRepository $user)
{
$this->user = $user;
}
/** /**
* Reset Password * Reset Password
* @param ResetPasswordRequest * @param Request
* @param JWTAuth * @param JWTAuth
* *
* @return \Illuminate\Http\JsonResponse * @return \Illuminate\Http\JsonResponse
*/ */
public function resetPassword(ResetPasswordRequest $request, JWTAuth $JWTAuth) public function reset(Request $request, JWTAuth $JWTAuth)
{ {
$validation = Validator::make($request->all(), [
'token' => 'required',
'email' => 'required|email',
'password' => 'required|min:4|confirmed|regex:"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).{8,}$"',
]);
if ($validation->fails()) {
return $this->throwValidation($validation->messages()->first());
}
dd('viral');
$response = $this->broker()->reset( $response = $this->broker()->reset(
$this->credentials($request), function ($user, $password) { $this->credentials($request), function ($user, $password) {
$this->reset($user, $password); $this->resetPassword($user, $password);
} }
); );
...@@ -57,10 +90,10 @@ class ResetPasswordController extends APIController ...@@ -57,10 +90,10 @@ class ResetPasswordController extends APIController
/** /**
* Get the password reset credentials from the request. * Get the password reset credentials from the request.
* *
* @param ResetPasswordRequest $request * @param $request
* @return array * @return array
*/ */
protected function credentials(ResetPasswordRequest $request) protected function credentials($request)
{ {
return $request->only( return $request->only(
'email', 'password', 'password_confirmation', 'token' 'email', 'password', 'password_confirmation', 'token'
...@@ -74,7 +107,7 @@ class ResetPasswordController extends APIController ...@@ -74,7 +107,7 @@ class ResetPasswordController extends APIController
* @param string $password * @param string $password
* @return void * @return void
*/ */
protected function reset($user, $password) protected function resetPassword($user, $password)
{ {
$user->password = $password; $user->password = $password;
$user->save(); $user->save();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment