Add new version in repository
This commit is contained in:
@@ -26,7 +26,7 @@ class ConfirmPasswordController extends Controller
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = RouteServiceProvider::HOME;
|
||||
protected $redirectTo = '';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
|
||||
@@ -19,4 +19,20 @@ class ForgotPasswordController extends Controller
|
||||
*/
|
||||
|
||||
use SendsPasswordResetEmails;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
|
||||
public function showLinkRequestForm()
|
||||
{
|
||||
$data = \App\Repositories\Config::init();
|
||||
return view('auth.passwords.email', $data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,38 +3,49 @@
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Repositories\Layout;
|
||||
use Carbon\Carbon;
|
||||
|
||||
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.
|
||||
|
|
||||
*/
|
||||
|
||||
use AuthenticatesUsers;
|
||||
protected $redirectTo = '/';
|
||||
|
||||
/**
|
||||
* Where to redirect users after login.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = RouteServiceProvider::HOME;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest')->except('logout');
|
||||
$this->middleware('guest:web')->except('logout');
|
||||
}
|
||||
|
||||
public function showLoginForm()
|
||||
{
|
||||
$data = \App\Repositories\Config::init();
|
||||
return view('auth.login', $data);
|
||||
}
|
||||
|
||||
public function authenticated(Request $request, $user)
|
||||
{
|
||||
$request->session()->forget('password_expired_id');
|
||||
|
||||
if ($user->passwordSecurity->password_expiry_days > 0) {
|
||||
$password_updated_at = $user->passwordSecurity->password_updated_at;
|
||||
$password_expiry_days = $user->passwordSecurity->password_expiry_days;
|
||||
$password_expiry_at = Carbon::parse($password_updated_at)->addDays($password_expiry_days);
|
||||
if ($password_expiry_at->lessThan(Carbon::now())) {
|
||||
$request->session()->put('password_expired_id', $user->id);
|
||||
auth()->logout();
|
||||
return redirect('/reset-password')->with('message', "Your password is expired. You need to change your password.");
|
||||
}
|
||||
}
|
||||
|
||||
return redirect()->intended($this->redirectPath());
|
||||
}
|
||||
|
||||
public function username()
|
||||
{
|
||||
return 'username';
|
||||
}
|
||||
}
|
||||
|
||||
71
app/Http/Controllers/Auth/PasswordSecurityController.php
Normal file
71
app/Http/Controllers/Auth/PasswordSecurityController.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class PasswordSecurityController extends Controller
|
||||
{
|
||||
// reset password form
|
||||
public function resetPasswordForm(Request $request)
|
||||
{
|
||||
$password_expired_id = $request->session()->get('password_expired_id');
|
||||
if (!isset($password_expired_id)) {
|
||||
return redirect('/login');
|
||||
}
|
||||
return view('auth.reset_password');
|
||||
}
|
||||
|
||||
// reset password
|
||||
public function resetPassword(Request $request)
|
||||
{
|
||||
// check expire id
|
||||
$password_expired_id = $request->session()->get('password_expired_id');
|
||||
if (!isset($password_expired_id)) {
|
||||
return redirect('/login');
|
||||
}
|
||||
|
||||
// validate
|
||||
$validatedData = $request->validate(
|
||||
[
|
||||
'current_password' => 'required',
|
||||
'new_password' => 'required|string|min:6|confirmed',
|
||||
]
|
||||
);
|
||||
|
||||
// the requests
|
||||
$request_current_password = $request->current_password;
|
||||
$request_new_password = $request->new_password;
|
||||
$request_new_password_confirm = $request->new_password_confirm;
|
||||
|
||||
// the passwords matches
|
||||
$user = User::find($password_expired_id);
|
||||
if (!(Hash::check($request_current_password, $user->password))) {
|
||||
return redirect()->back()->with("error", "Your current password does not matches with the password you provided. Please try again.");
|
||||
}
|
||||
|
||||
// current password and new password are same
|
||||
if (strcmp($request_current_password, $request->new_password) == 0) {
|
||||
return redirect()->back()->with("error", "New password cannot be same as your current password. Please choose a different password.");
|
||||
}
|
||||
|
||||
// new password and new password confirm doesn't match
|
||||
if (strcmp($request_new_password, $request_new_password_confirm) == 1) {
|
||||
return redirect()->back()->with("error", "New password doesn't match with confirm password.");
|
||||
}
|
||||
|
||||
// change Password
|
||||
$user->password = bcrypt($request->new_password);
|
||||
$user->save();
|
||||
|
||||
// update password update time
|
||||
$user->passwordSecurity->password_updated_at = Carbon::now();
|
||||
$user->passwordSecurity->save();
|
||||
|
||||
return redirect('/login')->with("status", "Password changed successfully. Now you can login!");
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,11 @@
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\User;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use App\Models\Core\Auth\User;
|
||||
use Illuminate\Foundation\Auth\RegistersUsers;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Foundation\Auth\RegistersUsers;
|
||||
|
||||
class RegisterController extends Controller
|
||||
{
|
||||
@@ -29,7 +28,7 @@ class RegisterController extends Controller
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = RouteServiceProvider::HOME;
|
||||
protected $redirectTo = '/home';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
@@ -38,36 +37,40 @@ class RegisterController extends Controller
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a validator for an incoming registration request.
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $data
|
||||
* @return \Illuminate\Contracts\Validation\Validator
|
||||
*/
|
||||
protected function validator(array $data)
|
||||
{
|
||||
return Validator::make($data, [
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
|
||||
'password' => ['required', 'string', 'min:8', 'confirmed'],
|
||||
]);
|
||||
return Validator::make(
|
||||
$data, [
|
||||
'name' => 'required|string|max:255',
|
||||
'email' => 'required|string|email|max:255|unique:users',
|
||||
'password' => 'required|string|min:6|confirmed',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new user instance after a valid registration.
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $data
|
||||
* @return \App\User
|
||||
*/
|
||||
protected function create(array $data)
|
||||
{
|
||||
return User::create([
|
||||
return User::create(
|
||||
[
|
||||
'name' => $data['name'],
|
||||
'email' => $data['email'],
|
||||
'password' => Hash::make($data['password']),
|
||||
]);
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
|
||||
class ResetPasswordController extends Controller
|
||||
@@ -26,5 +26,23 @@ class ResetPasswordController extends Controller
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = RouteServiceProvider::HOME;
|
||||
protected $redirectTo = '/home';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
|
||||
public function showResetForm(Request $request, $token = null)
|
||||
{
|
||||
$data = \App\Repositories\Config::init();
|
||||
$data['token'] = $token;
|
||||
$data['email'] = $request->email;
|
||||
return view('auth.passwords.reset', $data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Illuminate\Foundation\Auth\VerifiesEmails;
|
||||
|
||||
class VerificationController extends Controller
|
||||
@@ -26,7 +25,7 @@ class VerificationController extends Controller
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = RouteServiceProvider::HOME;
|
||||
protected $redirectTo = '/home';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
|
||||
Reference in New Issue
Block a user