From 0abaeb2ebab9c193d0c01cf064cb31f37dcf503f Mon Sep 17 00:00:00 2001 From: Torsten Date: Fri, 25 Aug 2017 12:57:58 +0200 Subject: [PATCH] Password reset working locally --- .../Auth/ForgotPasswordController.php | 11 -- .../Controllers/Auth/RegisterController.php | 2 +- .../app/Http/Controllers/HomeController.php | 28 +++++ .../Http/Controllers/RoundmailController.php | 105 ++++++------------ pfosten/config/app.php | 2 +- pfosten/config/mail.php | 9 +- pfosten/public/css/album.css | 6 +- pfosten/resources/lang/en/passwords.php | 10 +- pfosten/resources/views/auth/login.blade.php | 1 - .../views/auth/passwords/email.blade.php | 47 +++++++- .../views/auth/passwords/reset.blade.php | 10 +- .../resources/views/auth/register.blade.php | 1 - .../resources/views/emails/password.blade.php | 2 +- pfosten/resources/views/home.blade.php | 17 +++ pfosten/resources/views/layouts/app.blade.php | 80 +++++++++++++ .../resources/views/roundmails/show.blade.php | 4 + pfosten/routes/web.php | 28 +++-- pfosten/vendor/composer/autoload_classmap.php | 1 + pfosten/vendor/composer/autoload_static.php | 1 + .../make/views/auth/passwords/email.stub | 2 +- .../make/views/auth/passwords/reset.stub | 2 +- .../Auth/Notifications/ResetPassword.php | 6 +- .../resources/views/email.blade.php | 5 +- 23 files changed, 262 insertions(+), 118 deletions(-) create mode 100644 pfosten/app/Http/Controllers/HomeController.php create mode 100644 pfosten/resources/views/home.blade.php create mode 100644 pfosten/resources/views/layouts/app.blade.php diff --git a/pfosten/app/Http/Controllers/Auth/ForgotPasswordController.php b/pfosten/app/Http/Controllers/Auth/ForgotPasswordController.php index 4bce8461..6a247fef 100644 --- a/pfosten/app/Http/Controllers/Auth/ForgotPasswordController.php +++ b/pfosten/app/Http/Controllers/Auth/ForgotPasswordController.php @@ -29,15 +29,4 @@ class ForgotPasswordController extends Controller { $this->middleware('guest'); } - - /** - * Display the form to request a password reset link. - * - * @return \Illuminate\Http\Response - */ - public function showLinkRequestForm() - { - return view('auth.passwords.email'); - } - } diff --git a/pfosten/app/Http/Controllers/Auth/RegisterController.php b/pfosten/app/Http/Controllers/Auth/RegisterController.php index ed8d1b77..f77265ab 100644 --- a/pfosten/app/Http/Controllers/Auth/RegisterController.php +++ b/pfosten/app/Http/Controllers/Auth/RegisterController.php @@ -58,7 +58,7 @@ class RegisterController extends Controller * Create a new user instance after a valid registration. * * @param array $data - * @return User + * @return \App\User */ protected function create(array $data) { diff --git a/pfosten/app/Http/Controllers/HomeController.php b/pfosten/app/Http/Controllers/HomeController.php new file mode 100644 index 00000000..a3af7dd8 --- /dev/null +++ b/pfosten/app/Http/Controllers/HomeController.php @@ -0,0 +1,28 @@ +middleware('auth'); + } + + /** + * Show the application dashboard. + * + * @return \Illuminate\Http\Response + */ + public function index() + { + return view('home'); + } +} diff --git a/pfosten/app/Http/Controllers/RoundmailController.php b/pfosten/app/Http/Controllers/RoundmailController.php index a256795c..14f97ded 100644 --- a/pfosten/app/Http/Controllers/RoundmailController.php +++ b/pfosten/app/Http/Controllers/RoundmailController.php @@ -60,11 +60,9 @@ class RoundmailController extends Controller $missingJokerMailList=array(); $adminMailList=array(); - $topic=""; - //TODO: umrüsten für Anzeige von Bestandsmails - $send_date = date("d.m.Y h:i:s", time()); + $send_date = date("d.m.Y h:i:s", time()); Log::info("Users to check for missing tipps:" . sizeof($users)); foreach($users as $user) { @@ -120,7 +118,7 @@ class RoundmailController extends Controller - return view('roundmails.show',compact('mail_id','activeMailList','inactiveMailList','missingTippMailList','missingJokerMailList','adminMailList','send_date','user_id','topic', 'mail_message', 'recipients', 'sender_name','viewmode')); + return view('roundmails.show',compact('mail_id','activeMailList','inactiveMailList','missingTippMailList','missingJokerMailList','adminMailList','send_date','user_id','topic', 'mail_message', 'recipients', 'sender_name','viewmode')); } @@ -148,84 +146,47 @@ class RoundmailController extends Controller } */ - $u = new User(['email'=>'magus@zauberturm.de','name'=>'Torsten der Schneider']); + $r = new RoundmailMailer(); + $r->user_id = Auth::user()->id; + $r->send_date = Carbon\Carbon::now(); + $r->recipients = request('recipients'); + $r->topic = request('topic'); + $r->mail_message = str_replace("\n","
", request('message')); + // Die hier ist nur für die DB + $rm = new RoundMail(); + $rm->send_date=$r->send_date; + $rm->recipients=$r->recipients; + $rm->user_id=$r->user_id; + $rm->topic=$r->topic; + $rm->message=$r->mail_message; + $rm->save(); - $r = new RoundmailMailer(); - $r->user_id = Auth::user()->id; - $r->send_date = Carbon\Carbon::now(); - $r->recipients = request('recipients'); - $r->topic = request('topic'); - $r->mail_message = str_replace("\n","
", request('message')); + \Mail::to(explode(",",$r->recipients))->send($r); - // Die hier ist nur für die DB - $rm = new RoundMail(); - $rm->send_date=$r->send_date; - $rm->recipients=$r->recipients; - $rm->user_id=$r->user_id; - $rm->topic=$r->topic; - $rm->message=$r->mail_message; - $rm->save(); + // TODO: refactor, loop is also used in index method. + // COPY/PASTE, please refactor! + $mails_db = Roundmail::all(); + $mails=array(); + foreach($mails_db as $mail_db) { + $fields=array(); + $fields['id'] = $mail_db->id; + $fields['send_date'] = $mail_db->send_date; + $fields['topic'] = $mail_db->topic; - \Mail::to(explode(",",$r->recipients))->send($r); - - - - - - - // COPY/PAST, please replace ! - - - $user_id=Auth::user()->id; - - $users = DB::table('users')->where('deleted',null)->orderBy('lastname')->get(); - $active_users=array(); - $activeMailList=array(); - - - $inactive_users=array(); - $inactiveMailList=array(); - - $users_with_missing_tips=array(); // $users_with_missing_tips (or jokers) - $missingMailList=array(); - - $adminMailList=array(); - - $topic=""; - //TODO: umrüsten für Anzeige von Bestandsmails - $maildate = date("d.m.Y h:i:s", time()); - - foreach($users as $user) { - if (User::is_season_paid($user->id)) { - array_push($active_users,$user); - array_push($activeMailList,$user->email); - } else { - array_push($inactive_users, $user); - array_push($inactiveMailList,$user->email); - } - - if (User::hasMissingJoker($user->id) || User::hasMissingTipp($user->id)) { - array_push($users_with_missing_tips,$user); - array_push($missingMailList,$user->email); - } - - if ($user->admin) { - array_push($adminMailList,$user->email); - } + $sender = User::where('id','=',$mail_db->user_id)->first(); + $sender_name="(Gelöschter Anwender)"; + if ($sender) { $sender_name=$sender->name; } + $fields['sender'] = $sender_name; + array_push($mails,$fields); } + $mails=array_reverse($mails); - $activeMailList = implode(",",$activeMailList); - $inactiveMailList = implode(",",$inactiveMailList); - $missingMailList = implode(",",$missingMailList); - $adminMailList = implode(",",$adminMailList); + return view('roundmails.index',compact('mails')); - $round_id=-1; - return view('roundmails.show',compact('round_id','activeMailList','inactiveMailList','missingMailList','adminMailList','maildate','user_id','topic')); - } } diff --git a/pfosten/config/app.php b/pfosten/config/app.php index 76656969..7548ccf9 100644 --- a/pfosten/config/app.php +++ b/pfosten/config/app.php @@ -12,7 +12,7 @@ return [ | any other location as required by the application or its packages. */ - 'name' => env('APP_NAME', 'Laravel'), + 'name' => env('APP_NAME', 'Hoschis Tippspiel'), /* |-------------------------------------------------------------------------- diff --git a/pfosten/config/mail.php b/pfosten/config/mail.php index 29cd7be7..13b67247 100644 --- a/pfosten/config/mail.php +++ b/pfosten/config/mail.php @@ -16,7 +16,10 @@ return [ | */ - 'driver' => env('MAIL_DRIVER', 'smtp'), + //'driver' => env('MAIL_DRIVER', 'smtp'), + 'driver' => env('MAIL_DRIVER', 'log'), + + /* |-------------------------------------------------------------------------- @@ -66,8 +69,8 @@ return [ |-------------------------------------------------------------------------- | | Here you may specify the encryption protocol that should be used when - | the application send e-mail messages. A sensible default using the - | transport layer security protocol should provide great security. +| the application send e-mail messages. A sensible default using the +| transport layer security protocol should provide great security. | */ diff --git a/pfosten/public/css/album.css b/pfosten/public/css/album.css index 1bfc46f6..5491bd3e 100644 --- a/pfosten/public/css/album.css +++ b/pfosten/public/css/album.css @@ -60,7 +60,7 @@ footer p { .blink_text { - animation:1s blinker linear infinite; + animation: blinker 1s linear infinite; -webkit-animation:1s blinker linear infinite; -moz-animation:1s blinker linear infinite; @@ -80,7 +80,5 @@ footer p { } @keyframes blinker { - 0% { opacity: 1.0; } - 50% { opacity: 0.0; } - 100% { opacity: 1.0; } + 50% { opacity: 0; } } \ No newline at end of file diff --git a/pfosten/resources/lang/en/passwords.php b/pfosten/resources/lang/en/passwords.php index e5544d20..6a2d1704 100644 --- a/pfosten/resources/lang/en/passwords.php +++ b/pfosten/resources/lang/en/passwords.php @@ -13,10 +13,10 @@ return [ | */ - 'password' => 'Passwords must be at least six characters and match the confirmation.', - 'reset' => 'Your password has been reset!', - 'sent' => 'We have e-mailed your password reset link!', - 'token' => 'This password reset token is invalid.', - 'user' => "We can't find a user with that e-mail address.", + 'password' => 'Das Passwort muss mind. 6 Zeichen haben und beide Passwort-Eingaben müssen übereinstimmen', + 'reset' => 'Dein Passwort wurde zurückgesetzt!', + 'sent' => 'Wir haben Dir eine Rücksetzungs-Mail zugeschickt!', + 'token' => 'Ungültiges Password Reset Token.', + 'user' => "Es gibt keinen Spieler mit dieser E-Mail Adresse", ]; diff --git a/pfosten/resources/views/auth/login.blade.php b/pfosten/resources/views/auth/login.blade.php index 07924ce6..e0e0b580 100644 --- a/pfosten/resources/views/auth/login.blade.php +++ b/pfosten/resources/views/auth/login.blade.php @@ -6,7 +6,6 @@
Login
-
{{ csrf_field() }} diff --git a/pfosten/resources/views/auth/passwords/email.blade.php b/pfosten/resources/views/auth/passwords/email.blade.php index fbcb241c..b1fb089b 100644 --- a/pfosten/resources/views/auth/passwords/email.blade.php +++ b/pfosten/resources/views/auth/passwords/email.blade.php @@ -1 +1,46 @@ -Hallo Welt ! (email.blade.php) \ No newline at end of file +@extends('layouts.app') + +@section('content') +
+
+
+
+
Passwort zurücksetzen
+
+ @if (session('status')) +
+ {{ session('status') }} +
+ @endif + + + {{ csrf_field() }} + +
+ + +
+ + + @if ($errors->has('email')) + + {{ $errors->first('email') }} + + @endif +
+
+ +
+
+ +
+
+ +
+
+
+
+
+@endsection diff --git a/pfosten/resources/views/auth/passwords/reset.blade.php b/pfosten/resources/views/auth/passwords/reset.blade.php index 84ec0101..92d57511 100644 --- a/pfosten/resources/views/auth/passwords/reset.blade.php +++ b/pfosten/resources/views/auth/passwords/reset.blade.php @@ -5,9 +5,15 @@
-
Reset Password
+
Passwort zurücksetzen
+ @if (session('status')) +
+ {{ session('status') }} +
+ @endif +
{{ csrf_field() }} @@ -57,7 +63,7 @@
diff --git a/pfosten/resources/views/auth/register.blade.php b/pfosten/resources/views/auth/register.blade.php index 38eef838..5f11eee2 100644 --- a/pfosten/resources/views/auth/register.blade.php +++ b/pfosten/resources/views/auth/register.blade.php @@ -6,7 +6,6 @@
Register
-
{{ csrf_field() }} diff --git a/pfosten/resources/views/emails/password.blade.php b/pfosten/resources/views/emails/password.blade.php index 828a6714..c53689a3 100644 --- a/pfosten/resources/views/emails/password.blade.php +++ b/pfosten/resources/views/emails/password.blade.php @@ -1 +1 @@ -Click here to reset your password: {{ url('password/reset/'.$token) }} \ No newline at end of file +Hier klicken um Dein Passwort zurückzusetzen: {{ url('password/reset/'.$token) }} \ No newline at end of file diff --git a/pfosten/resources/views/home.blade.php b/pfosten/resources/views/home.blade.php new file mode 100644 index 00000000..de73a980 --- /dev/null +++ b/pfosten/resources/views/home.blade.php @@ -0,0 +1,17 @@ +@extends('layouts.app') + +@section('content') +
+
+
+
+
Dashboard
+ +
+ You are logged in! +
+
+
+
+
+@endsection diff --git a/pfosten/resources/views/layouts/app.blade.php b/pfosten/resources/views/layouts/app.blade.php new file mode 100644 index 00000000..d4745b4e --- /dev/null +++ b/pfosten/resources/views/layouts/app.blade.php @@ -0,0 +1,80 @@ + + + + + + + + + + + {{ config('app.name', 'Laravel') }} + + + + + +
+ + + @yield('content') +
+ + + + + diff --git a/pfosten/resources/views/roundmails/show.blade.php b/pfosten/resources/views/roundmails/show.blade.php index c6e38e6c..cce62216 100644 --- a/pfosten/resources/views/roundmails/show.blade.php +++ b/pfosten/resources/views/roundmails/show.blade.php @@ -13,7 +13,11 @@
+ @if($send_date) + @else + + @endif
diff --git a/pfosten/routes/web.php b/pfosten/routes/web.php index 131f5704..6e2db7a1 100644 --- a/pfosten/routes/web.php +++ b/pfosten/routes/web.php @@ -12,12 +12,13 @@ */ + Route::get('/','UsersController@main')->name('home'); Route::get('/register','RegistrationController@create'); Route::post('/register','RegistrationController@store'); -Route::get('/login','SessionsController@create'); +Route::get('/login','SessionsController@create')->name('login'); Route::post('/login','SessionsController@store'); Route::get('/logout','SessionsController@destroy'); @@ -55,18 +56,31 @@ Route::get('/roundmails','RoundmailController@index'); Route::get('/roundmails/show/{mail_id}','RoundmailController@show'); Route::post('/roundmails/send','RoundmailController@send'); +// php artisan route:list +//Auth::routes(); +Route::post('/password/email','Auth\ForgotPasswordController@sendResetLinkEmail')->name('password.email'); +Route::get('/password/reset','Auth\ForgotPasswordController@showLinkRequestForm')->name('password.request'); +Route::get('/password/reset/{token}','Auth\ResetPasswordController@showResetForm')->name('password.reset'); +Route::post('/password/reset','Auth\ResetPasswordController@reset'); +Route::get('/register','Auth\RegisterController@showRegistrationForm')->name('register'); -Route::get('/resetpassword','Auth\ResetPasswordController@showResetForm'); -Route::get('test','UsersController@test'); + + +//Route::get('/resetpassword','Auth\ResetPasswordController@showResetForm'); +//Route::get('test','UsersController@test'); /* Route::get('/reset','UsersController@reset')->name('password.email'); Route::post('/reset','UsersController@processReset')->name('password.request'); */ -Route::get('/password/reset','Auth\ForgotPasswordController@showLinkRequestForm')->name('password.request'); -Route::post('/password/email','Auth\ForgotPasswordController@sendResetLinkEmail')->name('password.email'); +//Route::get('/password/reset','Auth\ForgotPasswordController@showLinkRequestForm')->name('password.request'); +//Route::post('/password/email','Auth\ForgotPasswordController@sendResetLinkEmail')->name('password.email'); +//Route::get('/abc','Auth\ForgotPasswordController@abc'); + +//Auth::routes(); + +Route::get('/home', 'UsersController@main')->name('home'); + -Route::get('/abc','Auth\ForgotPasswordController@abc'); -//Route::auth(); \ No newline at end of file diff --git a/pfosten/vendor/composer/autoload_classmap.php b/pfosten/vendor/composer/autoload_classmap.php index 3f07c805..cb025987 100755 --- a/pfosten/vendor/composer/autoload_classmap.php +++ b/pfosten/vendor/composer/autoload_classmap.php @@ -15,6 +15,7 @@ return array( 'App\\Http\\Controllers\\Auth\\ResetPasswordController' => $baseDir . '/app/Http/Controllers/Auth/ResetPasswordController.php', 'App\\Http\\Controllers\\Controller' => $baseDir . '/app/Http/Controllers/Controller.php', 'App\\Http\\Controllers\\GamesController' => $baseDir . '/app/Http/Controllers/GamesController.php', + 'App\\Http\\Controllers\\HomeController' => $baseDir . '/app/Http/Controllers/HomeController.php', 'App\\Http\\Controllers\\PaymentController' => $baseDir . '/app/Http/Controllers/PaymentController.php', 'App\\Http\\Controllers\\RegistrationController' => $baseDir . '/app/Http/Controllers/RegistrationController.php', 'App\\Http\\Controllers\\RoundmailController' => $baseDir . '/app/Http/Controllers/RoundmailController.php', diff --git a/pfosten/vendor/composer/autoload_static.php b/pfosten/vendor/composer/autoload_static.php index 418a7203..06a2778a 100755 --- a/pfosten/vendor/composer/autoload_static.php +++ b/pfosten/vendor/composer/autoload_static.php @@ -287,6 +287,7 @@ class ComposerStaticInita19fb0695e1b61b4feeb3cc3fbdd2feb 'App\\Http\\Controllers\\Auth\\ResetPasswordController' => __DIR__ . '/../..' . '/app/Http/Controllers/Auth/ResetPasswordController.php', 'App\\Http\\Controllers\\Controller' => __DIR__ . '/../..' . '/app/Http/Controllers/Controller.php', 'App\\Http\\Controllers\\GamesController' => __DIR__ . '/../..' . '/app/Http/Controllers/GamesController.php', + 'App\\Http\\Controllers\\HomeController' => __DIR__ . '/../..' . '/app/Http/Controllers/HomeController.php', 'App\\Http\\Controllers\\PaymentController' => __DIR__ . '/../..' . '/app/Http/Controllers/PaymentController.php', 'App\\Http\\Controllers\\RegistrationController' => __DIR__ . '/../..' . '/app/Http/Controllers/RegistrationController.php', 'App\\Http\\Controllers\\RoundmailController' => __DIR__ . '/../..' . '/app/Http/Controllers/RoundmailController.php', diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/make/views/auth/passwords/email.stub b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/make/views/auth/passwords/email.stub index a29ac6df..b4f35848 100755 --- a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/make/views/auth/passwords/email.stub +++ b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/make/views/auth/passwords/email.stub @@ -33,7 +33,7 @@
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/make/views/auth/passwords/reset.stub b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/make/views/auth/passwords/reset.stub index e87d9cbd..f1bd77a4 100755 --- a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/make/views/auth/passwords/reset.stub +++ b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/make/views/auth/passwords/reset.stub @@ -63,7 +63,7 @@
diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Notifications/ResetPassword.php b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Notifications/ResetPassword.php index cd1ca866..908c52b6 100755 --- a/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Notifications/ResetPassword.php +++ b/pfosten/vendor/laravel/framework/src/Illuminate/Auth/Notifications/ResetPassword.php @@ -45,8 +45,8 @@ class ResetPassword extends Notification public function toMail($notifiable) { return (new MailMessage) - ->line('You are receiving this email because we received a password reset request for your account.') - ->action('Reset Password', url(config('app.url').route('password.reset', $this->token, false))) - ->line('If you did not request a password reset, no further action is required.'); + ->line('Du erhältst diese Mail, weil wir eine Anforderung zur Passwort-Rücksetzung erhalten haben.') + ->action('Passwort zurücksetzen', url(config('app.url').route('password.reset', $this->token, false))) + ->line('Wenn Du keine Rücksetzung angefordert hast, ignoriere diese Mail.'); } } diff --git a/pfosten/vendor/laravel/framework/src/Illuminate/Notifications/resources/views/email.blade.php b/pfosten/vendor/laravel/framework/src/Illuminate/Notifications/resources/views/email.blade.php index abfaa88e..c6bf97a9 100755 --- a/pfosten/vendor/laravel/framework/src/Illuminate/Notifications/resources/views/email.blade.php +++ b/pfosten/vendor/laravel/framework/src/Illuminate/Notifications/resources/views/email.blade.php @@ -45,14 +45,13 @@ @if (! empty($salutation)) {{ $salutation }} @else -Regards,
{{ config('app.name') }} +Beste Grüße,
{{ config('app.name') }} @endif {{-- Subcopy --}} @isset($actionText) @component('mail::subcopy') -If you’re having trouble clicking the "{{ $actionText }}" button, copy and paste the URL below -into your web browser: [{{ $actionUrl }}]({{ $actionUrl }}) +Sollte es Probleme mit dem "{{ $actionText }}" Knopf geben, Kopiere die folgende Adresse in Deinen Web Browser und lade sie: [{{ $actionUrl }}]({{ $actionUrl }}) @endcomponent @endisset @endcomponent