diff --git a/app/Http/Controllers/fireFightersController.php b/app/Http/Controllers/fireFightersController.php
index 1677613..10d34f6 100644
--- a/app/Http/Controllers/fireFightersController.php
+++ b/app/Http/Controllers/fireFightersController.php
@@ -8,6 +8,8 @@ use App\User;
use App\fireStation;
use App\Rules\Pesel;
use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Input;
+use Mail;
class fireFightersController extends Controller
{
@@ -82,8 +84,11 @@ class fireFightersController extends Controller
$request = request();
+ $confirmation_code = str_random(30);
+ $password = str_random(10);
+
$user = User::create([
- 'password' => '123',
+ 'password' => $password,
'email' => $request-> email,
'name' => $request-> name,
'surname' => $request-> surname,
@@ -94,9 +99,14 @@ class fireFightersController extends Controller
'number' => 'ABC123',
'fireStationID' => auth()->user()->fireStationID,
'creatorID' => auth()->user()-> id,
- 'changingID' => auth()->user()-> id
+ 'changingID' => auth()->user()-> id,
+ 'confirmation_code' => $confirmation_code,
]);
+ Mail::send('emails.newUserVerification', compact('password', 'confirmation_code'), function($message) {
+ $message->to(Input::get('email'), Input::get('name'))->subject('Witamy w serwisie eOSP');
+ });
+
return fireFightersController::create();
}
diff --git a/app/Http/Controllers/resetPasswordController.php b/app/Http/Controllers/resetPasswordController.php
new file mode 100644
index 0000000..c4b8d53
--- /dev/null
+++ b/app/Http/Controllers/resetPasswordController.php
@@ -0,0 +1,49 @@
+validate(request(), [
+ 'email' => 'required|email',
+ ],
+ [
+ 'required' => ':attribute jest wymagany.',
+ 'email' => 'Niepoprawny adres e-mail.'
+ ]);
+
+ $request = request();
+ $user = DB::table('users')->where('email', '=', $request->email)
+ ->first();
+
+ if($user){
+ $password = str_random(10);
+ User::where('email', '=', $request->email)
+ ->update(['password' => Hash::make($password)]); // this will also update the record
+ //$user->password = $password;
+ //$user->save();
+ Mail::send('emails.passwordReset', compact('password'), function($message) {
+ $message->to(Input::get('email'))->subject('Zmiana hasła');
+ });
+ }
+
+ return redirect()->to('/login')->with('success','Jeśli podany adres email jest poprawny, nowe hasło zostało wysłane');
+
+ }
+
+}
\ No newline at end of file
diff --git a/resources/views/emails/newUserVerification.blade.php b/resources/views/emails/newUserVerification.blade.php
new file mode 100644
index 0000000..77d2680
--- /dev/null
+++ b/resources/views/emails/newUserVerification.blade.php
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+ Witamy w serwisie eOSP
+
+
+ Twoje konto w serwisie eOSP zostało utworzone. Proszę kliknąć w link poniżej by dokonać weryfikacji adresu e-mail {{ URL::to('register/verify/' . $confirmation_code) }}
+
+ W razie problemów proszę wkleić powyższy link w polu adresowym przeglądarki internetowej.
+
+ Twoje domyślne hasło w serwisie eOSP: {{ $password }}
+
+ Po zalogowaniu możesz zmienić hasło w panelu Mój profil -> zmiana hasła.
+
+
+
+
+
\ No newline at end of file
diff --git a/resources/views/emails/passwordReset.blade.php b/resources/views/emails/passwordReset.blade.php
new file mode 100644
index 0000000..84a07e5
--- /dev/null
+++ b/resources/views/emails/passwordReset.blade.php
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+ Twoje hasło w serwisie eOSP zostało zresetowane
+
+
+ Twoje nowe hasło to: {{ $password }}
+
+ Po zalogowaniu możesz zmienić hasło w panelu Mój profil -> zmiana hasła.
+
+
+
+
+
\ No newline at end of file
diff --git a/resources/views/forgottenPassword.blade.php b/resources/views/forgottenPassword.blade.php
new file mode 100644
index 0000000..4a1c9f5
--- /dev/null
+++ b/resources/views/forgottenPassword.blade.php
@@ -0,0 +1,20 @@
+
+
+@extends('layout.app')
+
+@section('center-area')
+ @parent
+
+ Podaj adres email przypisany do Twojego konta. Nowe hasło zostanie wysłane na ten adres.
+
+
+@endsection
diff --git a/resources/views/login.blade.php b/resources/views/login.blade.php
index 3d1a4e9..8e1301d 100644
--- a/resources/views/login.blade.php
+++ b/resources/views/login.blade.php
@@ -2,7 +2,16 @@
@section('center-area')
@parent
- Log In
+
+ @if (\Session::has('success'))
+
+
+ - {!! \Session::get('success') !!}
+
+
+ @endif
+
+ Zaloguj się
+Nie pamiętam hasła
+
@endsection
diff --git a/resources/views/trainingsAddFireFighters.blade.php b/resources/views/trainingsAddFireFighters.blade.php
index aa7fc47..fc10f11 100644
--- a/resources/views/trainingsAddFireFighters.blade.php
+++ b/resources/views/trainingsAddFireFighters.blade.php
@@ -85,7 +85,7 @@
$.ajax({
type: 'post',
- url: '/szkolenia/addTrainingsFireFighters/',
+ url: '/szkolenia/addTrainingsFireFighters',
data: {
'firefighterID': firefighterID,
'trainingID': '{{$training->id}}',
@@ -149,7 +149,7 @@
$.ajax({
type: 'post',
- url: '/szkolenia/addTrainingsFireFighters/delete/',
+ url: '/szkolenia/addTrainingsFireFighters/delete',
data: {
'firefighterID': firefighterID,
'trainingID': '{{$training->id}}',
diff --git a/routes/web.php b/routes/web.php
index 7af19a5..001ca16 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -114,3 +114,6 @@ Route::get('register/verify/{confirmationCode}', [
Route::post('/pdf/sprzet', 'pdfController@createViewEquipment');
Route::get('/pdf/wniosek', 'pdfController@createViewDecoration');
Route::post('/pdf/strazacy', 'pdfController@createViewFireFighters');
+
+Route::get('/forgottenPassword', 'resetPasswordController@create');
+Route::post('/forgottenPassword', 'resetPasswordController@reset');