1
0
forked from s421507/eOSP2
This commit is contained in:
czup 2020-01-30 17:34:50 +01:00
commit 710a719170
8 changed files with 136 additions and 5 deletions

View File

@ -8,6 +8,8 @@ use App\User;
use App\fireStation; use App\fireStation;
use App\Rules\Pesel; use App\Rules\Pesel;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Input;
use Mail;
class fireFightersController extends Controller class fireFightersController extends Controller
{ {
@ -82,8 +84,11 @@ class fireFightersController extends Controller
$request = request(); $request = request();
$confirmation_code = str_random(30);
$password = str_random(10);
$user = User::create([ $user = User::create([
'password' => '123', 'password' => $password,
'email' => $request-> email, 'email' => $request-> email,
'name' => $request-> name, 'name' => $request-> name,
'surname' => $request-> surname, 'surname' => $request-> surname,
@ -94,9 +99,14 @@ class fireFightersController extends Controller
'number' => 'ABC123', 'number' => 'ABC123',
'fireStationID' => auth()->user()->fireStationID, 'fireStationID' => auth()->user()->fireStationID,
'creatorID' => auth()->user()-> id, '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(); return fireFightersController::create();
} }

View File

@ -0,0 +1,49 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Illuminate\Http\Request;
use App\User;
use Mail;
class resetPasswordController extends Controller
{
public function create()
{
return view('forgottenPassword');
}
public function reset()
{
$this->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');
}
}

View File

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
</head>
<body>
<h2>Witamy w serwisie eOSP</h2>
<div>
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) }}<br/>
W razie problemów proszę wkleić powyższy link w polu adresowym przeglądarki internetowej.<br/>
Twoje domyślne hasło w serwisie eOSP: {{ $password }}<br/>
Po zalogowaniu możesz zmienić hasło w panelu Mój profil -> zmiana hasła.
</div>
</body>
</html>

View File

@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
</head>
<body>
<h2>Twoje hasło w serwisie eOSP zostało zresetowane</h2>
<div>
Twoje nowe hasło to: {{ $password }}<br/>
Po zalogowaniu możesz zmienić hasło w panelu Mój profil -> zmiana hasła.
</div>
</body>
</html>

View File

@ -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. <br><br>
<form method="POST" action="/forgottenPassword">
{{ csrf_field() }}
<div class="form-group">
<input type="email" class="form-control" id="email" name="email">
</div>
<div class="form-group">
<button style="cursor:pointer" type="submit" class="btn btn-primary">Wyślij</button>
</div>
@include('inc.formerrors')
</form>
@endsection

View File

@ -2,7 +2,16 @@
@section('center-area') @section('center-area')
@parent @parent
<h2>Log In</h2>
@if (\Session::has('success'))
<div class="alert alert-success">
<ul>
<li>{!! \Session::get('success') !!}</li>
</ul>
</div>
@endif
<h2>Zaloguj się</h2>
<form method="POST" action="/login"> <form method="POST" action="/login">
{{ csrf_field() }} {{ csrf_field() }}
@ -22,4 +31,6 @@
@include('inc.formerrors') @include('inc.formerrors')
</form> </form>
<a href="/forgottenPassword">Nie pamiętam hasła<a>
@endsection @endsection

View File

@ -85,7 +85,7 @@
$.ajax({ $.ajax({
type: 'post', type: 'post',
url: '/szkolenia/addTrainingsFireFighters/', url: '/szkolenia/addTrainingsFireFighters',
data: { data: {
'firefighterID': firefighterID, 'firefighterID': firefighterID,
'trainingID': '{{$training->id}}', 'trainingID': '{{$training->id}}',
@ -149,7 +149,7 @@
$.ajax({ $.ajax({
type: 'post', type: 'post',
url: '/szkolenia/addTrainingsFireFighters/delete/', url: '/szkolenia/addTrainingsFireFighters/delete',
data: { data: {
'firefighterID': firefighterID, 'firefighterID': firefighterID,
'trainingID': '{{$training->id}}', 'trainingID': '{{$training->id}}',

View File

@ -114,3 +114,6 @@ Route::get('register/verify/{confirmationCode}', [
Route::post('/pdf/sprzet', 'pdfController@createViewEquipment'); Route::post('/pdf/sprzet', 'pdfController@createViewEquipment');
Route::get('/pdf/wniosek', 'pdfController@createViewDecoration'); Route::get('/pdf/wniosek', 'pdfController@createViewDecoration');
Route::post('/pdf/strazacy', 'pdfController@createViewFireFighters'); Route::post('/pdf/strazacy', 'pdfController@createViewFireFighters');
Route::get('/forgottenPassword', 'resetPasswordController@create');
Route::post('/forgottenPassword', 'resetPasswordController@reset');