From 9d5015aef238b9c12b3e04210f749302d51bc617 Mon Sep 17 00:00:00 2001 From: Kawlll Maxso Date: Fri, 22 Mar 2019 10:05:07 +0800 Subject: [PATCH 1/3] Forgot Account --- .../Accounts/ForgotAccountLogic.php | 62 +++++++++++++++++++ .../Account/ForgotAccountController.php | 50 +++++++++++++++ .../Auth/ForgotPasswordController.php | 5 ++ .../pages/authentication/forgot.blade.php | 55 ++++++++++++++++ routes/web.php | 3 + 5 files changed, 175 insertions(+) create mode 100644 app/Classes/Modules/ControllersLogic/Accounts/ForgotAccountLogic.php create mode 100644 app/Http/Controllers/Account/ForgotAccountController.php create mode 100644 resources/views/pages/authentication/forgot.blade.php diff --git a/app/Classes/Modules/ControllersLogic/Accounts/ForgotAccountLogic.php b/app/Classes/Modules/ControllersLogic/Accounts/ForgotAccountLogic.php new file mode 100644 index 0000000..b71e334 --- /dev/null +++ b/app/Classes/Modules/ControllersLogic/Accounts/ForgotAccountLogic.php @@ -0,0 +1,62 @@ +createUserInvitation = $createUserInvitation; + $this->canSendAccountInvitation = $canSendAccountInvitation; + } + + + /** + * @param Request $request + * @return JsonResponse + * @throws InternalServerErrorException + */ + public function execute(Request $request) { + + try { + + $object = new UserInvitationObject($request->get('role_id'), $request->get('email')); + + if($this->canSendAccountInvitation->execute($object)){ + + + $invitation = $this->createUserInvitation->execute($object); + + event(new UserInvited($invitation)); + + return new JsonResponse("Invitation have been sent!", HttpStatus::RESOURCE_CREATED); + } + + } catch (ResourceConflictException $exception) { + throw new InternalServerErrorException("Failed to send user invitation because {$exception->getMessage()}"); + } + } +} \ No newline at end of file diff --git a/app/Http/Controllers/Account/ForgotAccountController.php b/app/Http/Controllers/Account/ForgotAccountController.php new file mode 100644 index 0000000..7f8cddb --- /dev/null +++ b/app/Http/Controllers/Account/ForgotAccountController.php @@ -0,0 +1,50 @@ +execute($request); +// } +//} + + +namespace App\Http\Controllers\Account; + +use Illuminate\Support\Facades\Mail; +use Illuminate\Http\Request; +use App\Http\Controllers\Controller; + +class ForgotAccountController extends Controller +{ + /** + * Send an e-mail reminder to the user. + * + * @param Request $request + * @param int $id + * @return Response + */ + public function forgot() + { + + Mail::send('emails.reminder', ['user' => "ahmad"], function ($m) { + $m->from('2f114cfc66-6c1272@inbox.mailtrap.io', 'Your Application'); + + $m->to("2f114cfc66-6c1272@inbox.mailtrap.io", "ahmad")->subject('Your Reminder!'); + }); + } +} \ No newline at end of file diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php index 38e126f..46cbf98 100644 --- a/app/Http/Controllers/Auth/ForgotPasswordController.php +++ b/app/Http/Controllers/Auth/ForgotPasswordController.php @@ -28,4 +28,9 @@ class ForgotPasswordController extends Controller { $this->middleware('guest'); } + + public function showForgotForm() + { + return view('pages.authentication.forgot'); + } } diff --git a/resources/views/pages/authentication/forgot.blade.php b/resources/views/pages/authentication/forgot.blade.php new file mode 100644 index 0000000..1c71992 --- /dev/null +++ b/resources/views/pages/authentication/forgot.blade.php @@ -0,0 +1,55 @@ +@extends('layouts.base') + +@section('content') +
+
+
+
+
+
+
+
+ logo +
+
+
+
+
+

Forget Your Password

+

Reset it using your credentials

+
+
+
+
+
+
+
+ @if($errors->any()) + @foreach ($errors->all() as $error) +
{{ $error }}
+ @endforeach + @endif +
+
+ +
+
+ +
+ +
+
+
+
+ {{ csrf_field() }} + +
+
+ +
+
+
+
+
+
+@endsection \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index ffcba5a..17ba750 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,6 +1,7 @@ name('login'); +Route::get('/forgot', 'Auth\ForgotPasswordController@showForgotForm')->name('login'); Route::group(['prefix' => 'auth'], function () { Route::post('/login', 'Auth\LoginController@login')->name('auth.login'); @@ -9,6 +10,8 @@ Route::group(['prefix' => 'auth'], function () { Route::post('/registration/create', 'Account\RegisterAccountController@register')->name('auth.registration.create'); + Route::post('/forgot', 'Account\ForgotAccountController@forgot')->name('auth.forgot'); + Route::get('/logout', 'Auth\LoginController@logout')->name('auth.logout'); }); From 0eda89eb26c63716bfe3da7bf797ba85b87a06fa Mon Sep 17 00:00:00 2001 From: Kawlll Maxso Date: Mon, 25 Mar 2019 16:03:01 +0800 Subject: [PATCH 2/3] Forgot and change password --- resources/views/pages/authentication/forgot.blade.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/resources/views/pages/authentication/forgot.blade.php b/resources/views/pages/authentication/forgot.blade.php index 1c71992..3dba811 100644 --- a/resources/views/pages/authentication/forgot.blade.php +++ b/resources/views/pages/authentication/forgot.blade.php @@ -52,4 +52,8 @@ -@endsection \ No newline at end of file +<<<<<<< Updated upstream +@endsection +======= +@endsection +>>>>>>> Stashed changes From 4f36e4909a36b7e79e2a3356fb475253bc974565 Mon Sep 17 00:00:00 2001 From: Kawlll Maxso Date: Thu, 28 Mar 2019 16:16:28 +0800 Subject: [PATCH 3/3] Forgot and change password --- .../Auth/ForgotPasswordController.php | 5 - .../pages/authentication/login.blade.php | 2 +- .../authentication/password/change.blade.php | 120 ++++++++++++++++++ .../{ => password}/forgot.blade.php | 51 ++++++-- routes/web.php | 12 +- 5 files changed, 172 insertions(+), 18 deletions(-) create mode 100644 resources/views/pages/authentication/password/change.blade.php rename resources/views/pages/authentication/{ => password}/forgot.blade.php (51%) diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php index 46cbf98..38e126f 100644 --- a/app/Http/Controllers/Auth/ForgotPasswordController.php +++ b/app/Http/Controllers/Auth/ForgotPasswordController.php @@ -28,9 +28,4 @@ class ForgotPasswordController extends Controller { $this->middleware('guest'); } - - public function showForgotForm() - { - return view('pages.authentication.forgot'); - } } diff --git a/resources/views/pages/authentication/login.blade.php b/resources/views/pages/authentication/login.blade.php index d6d7809..f2579d6 100644 --- a/resources/views/pages/authentication/login.blade.php +++ b/resources/views/pages/authentication/login.blade.php @@ -60,7 +60,7 @@
- Forgot your password? + Forgot your password?
diff --git a/resources/views/pages/authentication/password/change.blade.php b/resources/views/pages/authentication/password/change.blade.php new file mode 100644 index 0000000..949e9b4 --- /dev/null +++ b/resources/views/pages/authentication/password/change.blade.php @@ -0,0 +1,120 @@ +@extends('layouts.base') + +@section('content') +
+
+
+
+
+
+
+
+ logo +
+
+
+
+
+

Change Your Password

+
+
+
+
+
+
+
+ @if($errors->any()) + @foreach ($errors->all() as $error) +
{{ $error }}
+ @endforeach + @endif +
+
+
+ @csrf + +
+ +
+ +
+
+
+ +
+ + @if ($errors->has('password')) + + {{ $errors->first('password') }} + + @endif +
+
+
+ +
+ +
+
+
+
+ +
+
+
+ + {{--
--}} + {{--@csrf--}} + + {{----}} + + {{--
--}} + {{----}} + + {{--
--}} + {{----}} + + {{--@if ($errors->has('email'))--}} + {{----}} + {{--{{ $errors->first('email') }}--}} + {{----}} + {{--@endif--}} + {{--
--}} + {{--
--}} + + {{--
--}} + {{----}} + + {{--
--}} + {{----}} + + {{--@if ($errors->has('password'))--}} + {{----}} + {{--{{ $errors->first('password') }}--}} + {{----}} + {{--@endif--}} + {{--
--}} + {{--
--}} + + {{--
--}} + {{----}} + + {{--
--}} + {{----}} + {{--
--}} + {{--
--}} + + {{--
--}} + {{--
--}} + {{----}} + {{--
--}} + {{--
--}} + {{--
--}} +
+
+
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/pages/authentication/forgot.blade.php b/resources/views/pages/authentication/password/forgot.blade.php similarity index 51% rename from resources/views/pages/authentication/forgot.blade.php rename to resources/views/pages/authentication/password/forgot.blade.php index 3dba811..b8d9336 100644 --- a/resources/views/pages/authentication/forgot.blade.php +++ b/resources/views/pages/authentication/password/forgot.blade.php @@ -1,6 +1,33 @@ @extends('layouts.base') @section('content') + @if (session('status')) +
+
+
+
+
+
+
+ +
We just sent an email to reset your password
+

Click on the link we've sent you to reset your password. + if you have not received an email, Please check your spambox

+
+ +
+
+
+
+
+
+ @else
@@ -31,29 +58,35 @@ @endif
- -
+ + @csrf +
- + +
+
+ + @if ($errors->has('email')) + + {{ $errors->first('email') }} + + @endif
+
{{ csrf_field() }}
-
-<<<<<<< Updated upstream -@endsection -======= -@endsection ->>>>>>> Stashed changes + @endif +@endsection \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 17ba750..f990d7a 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,7 +1,6 @@ name('login'); -Route::get('/forgot', 'Auth\ForgotPasswordController@showForgotForm')->name('login'); Route::group(['prefix' => 'auth'], function () { Route::post('/login', 'Auth\LoginController@login')->name('auth.login'); @@ -10,7 +9,14 @@ Route::group(['prefix' => 'auth'], function () { Route::post('/registration/create', 'Account\RegisterAccountController@register')->name('auth.registration.create'); - Route::post('/forgot', 'Account\ForgotAccountController@forgot')->name('auth.forgot'); + Route::get('password/forgot', function () { + return view('pages.authentication.password.forgot'); + })->name('password.forgot'); + Route::post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail')->name('password.email'); + Route::get('password/reset/{token}', function ($token){ + return view('pages.authentication.password.change',['token' => $token]); + })->name('password.reset'); + Route::post('password/update', 'Auth\ResetPasswordController@reset')->name('password.update'); Route::get('/logout', 'Auth\LoginController@logout')->name('auth.logout'); }); @@ -47,7 +53,7 @@ Route::group(['middleware' => ['secure', 'clearcache']], function (): void { Route::get('/order/profile', function(){ return view('pages.orders.profile'); })->name('order.profile'); - + });