diff --git a/app/Classes/Modules/Accounts/ControllerLogic/AuthenticateUserLogic.php b/app/Classes/Modules/Accounts/ControllerLogic/AuthenticateUserLogic.php new file mode 100644 index 00000000..432a9eeb --- /dev/null +++ b/app/Classes/Modules/Accounts/ControllerLogic/AuthenticateUserLogic.php @@ -0,0 +1,71 @@ + 'Authentication', + 'message' => 'You have successfully logged in to your account' + ]; + } + + /** @var CanAuthenticateUser */ + private $canAuthenticateUser; + + /** @var AuthenticatesUser */ + private $authenticatesUser; + + /** @var AuthenticationRedirect */ + private $authenticationRedirect; + + /** + * AuthenticateUserLogic constructor. + * @param CanAuthenticateUser $canAuthenticateUser + * @param AuthenticatesUser $authenticatesUser + * @param AuthenticationRedirect $authenticationRedirect + */ + public function __construct(CanAuthenticateUser $canAuthenticateUser, AuthenticatesUser $authenticatesUser, AuthenticationRedirect $authenticationRedirect) + { + $this->canAuthenticateUser = $canAuthenticateUser; + $this->authenticatesUser = $authenticatesUser; + $this->authenticationRedirect = $authenticationRedirect; + } + + + /** + * @param Request $request + * @return JsonResponse + * @throws ErrorException + */ + protected function logic(Request $request): JsonResponse { + + try { + $object = new AuthenticationCredentialsObject($request->input('email'), + $request->input('password'), $request->input('remember_me')); + + $this->canAuthenticateUser->passes($object); + + $token = $this->authenticatesUser->execute($object); + + return $this->response(['access_token' => $token, 'redirect_url' => $this->authenticationRedirect->url()]); + + } catch (\Exception $exception){ + throw new ErrorException($exception->getMessage(), $exception->getCode()); + } + + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Accounts/DataTransferObjects/AuthenticationCredentialsObject.php b/app/Classes/Modules/Accounts/DataTransferObjects/AuthenticationCredentialsObject.php new file mode 100644 index 00000000..874c25fa --- /dev/null +++ b/app/Classes/Modules/Accounts/DataTransferObjects/AuthenticationCredentialsObject.php @@ -0,0 +1,59 @@ +email = $email; + $this->password = $password; + $this->rememberUser = $rememberUser; + } + + /** + * @return string + */ + public function getEmail(): string + { + return $this->email; + } + + /** + * @return string + */ + public function getPassword(): string + { + return $this->password; + } + + /** + * @return bool + */ + public function isRememberUser(): bool + { + return $this->rememberUser; + } + + + +} \ No newline at end of file diff --git a/app/Classes/Modules/Accounts/Services/AuthenticatesUser.php b/app/Classes/Modules/Accounts/Services/AuthenticatesUser.php new file mode 100644 index 00000000..40a89cce --- /dev/null +++ b/app/Classes/Modules/Accounts/Services/AuthenticatesUser.php @@ -0,0 +1,27 @@ + $object->getEmail(), 'password' => $object->getPassword()])) { + throw new AccessUnauthorisedException('These credentials do not match our records.'); + } + + return $token; + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Accounts/Services/AuthenticationRedirect.php b/app/Classes/Modules/Accounts/Services/AuthenticationRedirect.php new file mode 100644 index 00000000..397a31d9 --- /dev/null +++ b/app/Classes/Modules/Accounts/Services/AuthenticationRedirect.php @@ -0,0 +1,12 @@ +userAuthenticationValidation = $userAuthenticationValidation; + } + + /** + * @return bool + */ + protected function authorized(): bool + { + return true; + + } + + + /** + * @param AuthenticationCredentialsObject $object + * @return bool + * @throws RequestValidationException + */ + protected function validators($object): bool + { + return $this->userAuthenticationValidation->validate($object); + + } + + + /** + * @param AuthenticationCredentialsObject $object + * @return bool + */ + protected function criteria($object): bool + { + return true; + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Accounts/Standards/Validators/UserAuthenticationValidation.php b/app/Classes/Modules/Accounts/Standards/Validators/UserAuthenticationValidation.php new file mode 100644 index 00000000..6142f769 --- /dev/null +++ b/app/Classes/Modules/Accounts/Standards/Validators/UserAuthenticationValidation.php @@ -0,0 +1,43 @@ + $object->getEmail(), + 'password' => $object->getPassword() + ]; + } + + /** + * @return array + */ + protected function rules(): array { + return [ + 'email' => 'required|email', + 'password' => 'required' + ]; + } + + /** + * @return array + */ + protected function messages(): array { + return []; + } + + + + +} \ No newline at end of file diff --git a/app/Http/Controllers/Accounts/UserAuthenticationController.php b/app/Http/Controllers/Accounts/UserAuthenticationController.php new file mode 100644 index 00000000..df63d703 --- /dev/null +++ b/app/Http/Controllers/Accounts/UserAuthenticationController.php @@ -0,0 +1,21 @@ +execute($request); + } + +} diff --git a/resources/assets/vue/components/accounts/forms/LoginFormComponent.vue b/resources/assets/vue/components/accounts/forms/LoginFormComponent.vue new file mode 100644 index 00000000..26e5c5ce --- /dev/null +++ b/resources/assets/vue/components/accounts/forms/LoginFormComponent.vue @@ -0,0 +1,99 @@ + + + + + + + + {{error}} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Login + + + Forgot Password ? + + + + + + \ No newline at end of file diff --git a/resources/views/pages/accounts/authentication/login.blade.php b/resources/views/pages/accounts/authentication/login.blade.php index 1a217cac..f5059196 100644 --- a/resources/views/pages/accounts/authentication/login.blade.php +++ b/resources/views/pages/accounts/authentication/login.blade.php @@ -1,93 +1,5 @@ @extends('layouts.base_login') @section('inner_content') - - - - - - ... - - - - - - - - - - - - - - - - - - - Did you forget your password? - - - - - Enter your email address you're using for your account belowand we will send you a password reset link - - - - - - - - - - - - - - - - - - - - - - - - - - - - Login Successful - - - - - Please wait for redirect - - - - - - - - - - - - reset your password - - - - we have sent a reset password email to Please click the reset password link to set your new password. - - - didn't receive the email yet ? Please check your spam folder, or resend the email - - - Did you remember your password? Go back to login - - - - + @endsection \ No newline at end of file diff --git a/resources/views/pages/accounts/list_users_example.blade.php b/resources/views/pages/accounts/list_users_example.blade.php deleted file mode 100644 index b1f4b518..00000000 --- a/resources/views/pages/accounts/list_users_example.blade.php +++ /dev/null @@ -1,15 +0,0 @@ -@extends('layouts.base_portal') -@section('inner_content') - - - - - Active users - List of the system currently active users - - - - - - -@endSection \ No newline at end of file diff --git a/resources/views/pages/accounts/registration.blade.php b/resources/views/pages/accounts/registration.blade.php index 1b62d2ae..7635b6de 100644 --- a/resources/views/pages/accounts/registration.blade.php +++ b/resources/views/pages/accounts/registration.blade.php @@ -1,4 +1,4 @@ -@extends('layouts.base_portal') +@extends('layouts.base_login') @section('inner_content') @endSection \ No newline at end of file diff --git a/routes/account.php b/routes/account.php index eff6dd7b..c2dacf1c 100644 --- a/routes/account.php +++ b/routes/account.php @@ -6,10 +6,9 @@ Route::group(['prefix' => 'account', 'namespace' => 'Accounts', 'as' => 'account Route::group(['prefix' => 'authentication', 'as' => 'authentication.'], function () { - // Route::group(['prefix' => 'login', 'as' => 'authenticate.'], function () { - // Route::post('/attempt', 'UserAuthenticationController@authenticate')->name('attempt'); - // Route::post('/check_email', 'CheckEmailController@check')->name('email.check'); - // }); + Route::group(['prefix' => 'login', 'as' => 'authenticate.'], function () { + Route::post('/attempt', 'UserAuthenticationController@authenticate')->name('attempt'); + }); // Route::group(['prefix' => 'password', 'as' => 'password.'], function () { // Route::post('/forget', 'GeneratePasswordResetController@generate')->name('forget'); diff --git a/routes/web.php b/routes/web.php index ad5df0c0..6d424aff 100644 --- a/routes/web.php +++ b/routes/web.php @@ -25,3 +25,7 @@ Route::get('account/registration', function () { Route::get('account/password/reset/{token}', function ($token){ return view('pages.accounts.authentication.reset_password',['token' => $token]); })->name('account.password.reset'); + +route::get('dashboard/', function (){ + return 'dashboard page here'; +})->name('dashboard');
Enter your email address you're using for your account belowand we will send you a password reset link
List of the system currently active users