Commit a9388bc9 authored by Viral Solani's avatar Viral Solani

Forgot Password API

parent ae08355c
......@@ -39,7 +39,7 @@ class AuthController extends APIController
return $this->respond([
'message' => trans('api.messages.login.success'),
'token' => $token,
'token' => $token
]);
}
......
......@@ -2,11 +2,12 @@
namespace App\Http\Controllers\Api\V1;
use Validator;
use App\Models\User\User;
use App\Notifications\UserNeedsPasswordReset;
use App\Repositories\UserRepository;
use Illuminate\Http\Request;
use Validator;
use App\Repositories\Frontend\Access\User\UserRepository;
use App\Notifications\Frontend\Auth\UserNeedsPasswordReset;
class ForgotPasswordController extends APIController
{
......@@ -37,7 +38,7 @@ class ForgotPasswordController extends APIController
return $this->throwValidation($validation->messages()->first());
}
$user = $this->repository->getUserByEmail($request);
$user = $this->repository->findByEmail($request->get('email'));
if (!$user) {
return $this->respondNotFound(trans('api.messages.forgot_password.validation.email_not_found'));
......
......@@ -5,6 +5,7 @@ namespace App\Repositories\Frontend\Access\User;
use App\Events\Frontend\Auth\UserConfirmed;
use App\Exceptions\GeneralException;
use App\Models\Access\User\SocialLogin;
use Illuminate\Support\Str;
use App\Models\Access\User\User;
use App\Notifications\Frontend\Auth\UserNeedsConfirmation;
use App\Repositories\Backend\Access\Role\RoleRepository;
......@@ -286,4 +287,21 @@ class UserRepository extends BaseRepository
throw new GeneralException(trans('exceptions.frontend.auth.password.change_mismatch'));
}
/**
* Create a new token for the user.
*
* @return string
*/
public function createNewToken()
{
$token = hash_hmac('sha256', Str::random(40), 'hashKey');
\DB::table('password_resets')->insert([
'email' => request('email'),
'token' => $token,
]);
return $token;
}
}
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