This repository has been archived by the owner on Aug 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
71 changed files
with
43,627 additions
and
1,124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Auth; | ||
|
||
use App\Http\Controllers\Controller; | ||
use Illuminate\Foundation\Auth\SendsPasswordResetEmails; | ||
|
||
class ForgotPasswordController extends Controller | ||
{ | ||
/* | ||
|-------------------------------------------------------------------------- | ||
| Password Reset Controller | ||
|-------------------------------------------------------------------------- | ||
| | ||
| This controller is responsible for handling password reset emails and | ||
| includes a trait which assists in sending these notifications from | ||
| your application to your users. Feel free to explore this trait. | ||
| | ||
*/ | ||
|
||
use SendsPasswordResetEmails; | ||
|
||
/** | ||
* Create a new controller instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct() | ||
{ | ||
$this->middleware('guest'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Auth; | ||
|
||
use App\Http\Controllers\Controller; | ||
use Illuminate\Support\Facades\Auth; | ||
use App\User; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\DB; | ||
|
||
class LoginController extends Controller | ||
{ | ||
/* | ||
|-------------------------------------------------------------------------- | ||
| Login Controller | ||
|-------------------------------------------------------------------------- | ||
| | ||
| This controller handles authenticating users for the application and | ||
| redirecting them to your home screen. The controller uses a trait | ||
| to conveniently provide its functionality to your applications. | ||
| | ||
*/ | ||
|
||
/** | ||
* Where to redirect users after login. | ||
* | ||
* @var string | ||
*/ | ||
protected $redirectTo = '/dashboard'; | ||
|
||
/** @var array to store seeder logins for site users */ | ||
protected $loginEmails = array( | ||
array( | ||
'email' => '[email protected]', | ||
'role' => 'admin', | ||
), | ||
array( | ||
'email' => '[email protected]', | ||
'role' => 'client_admin', | ||
), | ||
array( | ||
'email' => '[email protected]', | ||
'role' => 'client_user', | ||
), | ||
); | ||
|
||
/** | ||
* Create a new controller instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct() | ||
{ | ||
$this->middleware('guest')->except('create', 'logout'); | ||
} | ||
|
||
public function create() | ||
{ | ||
if(Auth::check()) { | ||
return redirect()->route('Dashboard'); | ||
} | ||
|
||
return view('auth/login') | ||
->withTitle('Login') | ||
->withLoginEmails($this->loginEmails); | ||
} | ||
|
||
public function store(Request $request) | ||
{ | ||
$email = strtolower( trim( request('email') ) ); | ||
|
||
if(($email && request('password')) == FALSE) | ||
{ | ||
return back()->with('errors', ['Missing email and password.']); | ||
} | ||
|
||
if(!$user = DB::select('select distinct * from users where email = ?', [$email])) | ||
{ | ||
return back()->with('errors', ['Invalid login credentials provided.']); | ||
} | ||
|
||
$user = $user[0]; | ||
|
||
if(!Auth::attempt(['email' => $user->email, | ||
'password' => request('password')], | ||
(int) request('remember_me'))) | ||
{ | ||
return back()->with('errors', ['Invalid login credentials provided.']); | ||
} | ||
|
||
DB::table('users')->update([ | ||
'last_login' => date('Y-m-d H:i:s') | ||
]); | ||
|
||
return redirect() | ||
->route('Dashboard') | ||
->with('flashSuccess', 'You have logged in, '.$user->first_name.' '.$user->last_name.'!'); | ||
} | ||
|
||
public function logout() | ||
{ | ||
Auth::logout(); | ||
|
||
return redirect('/'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Auth; | ||
|
||
use App\User; | ||
use App\Http\Controllers\Controller; | ||
use Illuminate\Support\Facades\Validator; | ||
use Illuminate\Foundation\Auth\RegistersUsers; | ||
use Auth; | ||
|
||
class RegisterController extends Controller | ||
{ | ||
/* | ||
|-------------------------------------------------------------------------- | ||
| Register Controller | ||
|-------------------------------------------------------------------------- | ||
| | ||
| This controller handles the registration of new users as well as their | ||
| validation and creation. By default this controller uses a trait to | ||
| provide this functionality without requiring any additional code. | ||
| | ||
*/ | ||
|
||
use RegistersUsers; | ||
|
||
/** | ||
* Where to redirect users after registration. | ||
* | ||
* @var string | ||
*/ | ||
protected $redirectTo = '/home'; | ||
|
||
/** | ||
* Create a new controller instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct() | ||
{ | ||
$this->middleware('guest'); | ||
} | ||
|
||
/** | ||
* Get a validator for an incoming registration request. | ||
* | ||
* @param array $data | ||
* @return \Illuminate\Contracts\Validation\Validator | ||
*/ | ||
protected function validator(array $data) | ||
{ | ||
return Validator::make($data, [ | ||
'user_created' => 'integer', | ||
'username' => 'required|string|max:191|unique:users', | ||
'first_name' => 'required|string|max:191', | ||
'last_name' => 'required|string|max:191', | ||
'email' => 'required|string|email|max:191|unique:users', | ||
'password' => 'required|string|min:6|confirmed', | ||
'contact_number' => 'required|string|max:191', | ||
'street_name' => 'required|string|max:191', | ||
'building_number' => 'required|string|max:191', | ||
'city' => 'required|string|max:191', | ||
'postcode' => 'required|string|max:191' | ||
]); | ||
} | ||
|
||
/** | ||
* Create a new user instance after a valid registration. | ||
* | ||
* @param array $data | ||
* @return \App\User | ||
*/ | ||
protected function createUser(array $data) | ||
{ | ||
return User::create([ | ||
'username' => trim($data['username']), | ||
'first_name' => trim($data['first_name']), | ||
'last_name' => trim($data['last_name']), | ||
'email' => trim($data['email']), | ||
'password' => bcrypt($data['password']), | ||
'contact_number' => trim($data['contact_number']), | ||
'street_name' => trim($data['street_name']), | ||
'city' => trim($data['city']), | ||
'postcode' => trim($data['postcode']) | ||
]); | ||
} | ||
|
||
public function create() | ||
{ | ||
if(Auth::check()) { | ||
return redirect('/'); | ||
} | ||
return view('auth.register')->withTitle('Register'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Auth; | ||
|
||
use App\Http\Controllers\Controller; | ||
use Illuminate\Foundation\Auth\ResetsPasswords; | ||
use Auth; | ||
|
||
class ResetPasswordController extends Controller | ||
{ | ||
/* | ||
|-------------------------------------------------------------------------- | ||
| Password Reset Controller | ||
|-------------------------------------------------------------------------- | ||
| | ||
| This controller is responsible for handling password reset requests | ||
| and uses a simple trait to include this behavior. You're free to | ||
| explore this trait and override any methods you wish to tweak. | ||
| | ||
*/ | ||
|
||
use ResetsPasswords; | ||
|
||
/** | ||
* Where to redirect users after resetting their password. | ||
* | ||
* @var string | ||
*/ | ||
protected $redirectTo = '/home'; | ||
|
||
/** | ||
* Create a new controller instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct() | ||
{ | ||
$this->middleware('guest'); | ||
} | ||
|
||
public function create() | ||
{ | ||
|
||
return view('auth.forgot')->withTitle('Reset Password'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Auth; | ||
|
||
use App\Http\Controllers\Controller; | ||
use Illuminate\Http\Request; | ||
use Validator; | ||
use App\User; | ||
use Auth; | ||
|
||
class UserSettingsController extends Controller | ||
{ | ||
/** | ||
* Where to redirect users after registration. | ||
* | ||
* @var string | ||
*/ | ||
protected $redirectTo = '/home'; | ||
|
||
public function edit() | ||
{ | ||
return view('settings.edit', [ | ||
'title'=>'User Settings', | ||
'user' =>auth()->user(), | ||
]); | ||
} | ||
|
||
public function update(Request $request) | ||
{ | ||
$user = auth()->user(); | ||
|
||
$validator = Validator::make($request->all(), [ | ||
'first_name' => 'max:191', | ||
'last_name' => 'max:191', | ||
'email' => 'required|email|max:191', | ||
// optional | ||
'building_number' => 'max:191', | ||
'street_name' => 'max:191', | ||
'city' => 'max:191', | ||
'postcode' => 'max:191', | ||
'contact_number' => 'max:191', | ||
]); | ||
$errors = $validator->errors()->all(); | ||
|
||
if(empty($errors)) | ||
{ | ||
$user->updateUser($request); | ||
|
||
return redirect()->back()->with('flashSuccess', 'Your settings have been updated.'); | ||
} | ||
else | ||
{ | ||
return view('settings.edit', [ | ||
'title'=>'User Settings', | ||
'user' =>auth()->user(), | ||
'errors' => $validator->errors()->all(), | ||
]); | ||
} | ||
} | ||
} |
Oops, something went wrong.