├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── bootstrap └── module.php ├── composer.json ├── config └── config.php ├── database ├── migrations │ ├── 2021_01_01_000001_create_admins_table.php │ ├── 2021_01_01_000003_create_members_table.php │ ├── 2021_01_01_000004_create_guardians_table.php │ ├── 2021_01_01_000005_create_abilities_table.php │ ├── 2021_01_01_000006_create_permissions_table.php │ ├── 2021_01_01_000007_create_roles_table.php │ ├── 2021_01_01_000008_create_assigned_roles_table.php │ ├── 2021_01_01_000009_create_sessions_table.php │ └── 2021_01_01_000010_create_socialites_table.php └── seeders │ └── CortexAuthSeeder.php ├── phpstan.neon.dist ├── resources ├── lang │ └── en │ │ ├── common.php │ │ ├── emails.php │ │ ├── messages.php │ │ └── twofactor.php └── views │ ├── adminarea │ ├── pages │ │ ├── ability.blade.php │ │ ├── account-index.blade.php │ │ ├── account-password.blade.php │ │ ├── account-sessions.blade.php │ │ ├── account-settings.blade.php │ │ ├── account-twofactor-totp.blade.php │ │ ├── account-twofactor.blade.php │ │ ├── admin.blade.php │ │ ├── admins.blade.php │ │ ├── authentication.blade.php │ │ ├── guardian.blade.php │ │ ├── member.blade.php │ │ ├── members.blade.php │ │ ├── passwordreset-request.blade.php │ │ ├── passwordreset.blade.php │ │ ├── reauthentication-password.blade.php │ │ ├── reauthentication-twofactor.blade.php │ │ ├── role.blade.php │ │ ├── verification-email-request.blade.php │ │ ├── verification-phone-request.blade.php │ │ └── verification-phone-token.blade.php │ └── partials │ │ ├── datatable-filters.blade.php │ │ └── sidebar.blade.php │ └── frontarea │ ├── pages │ ├── account-index.blade.php │ ├── account-password.blade.php │ ├── account-sessions.blade.php │ ├── account-settings.blade.php │ ├── account-twofactor-totp.blade.php │ ├── account-twofactor.blade.php │ ├── authentication.blade.php │ ├── member-registration.blade.php │ ├── passwordreset-request.blade.php │ ├── passwordreset.blade.php │ ├── reauthentication-password.blade.php │ ├── reauthentication-twofactor.blade.php │ ├── verification-email-request.blade.php │ ├── verification-phone-request.blade.php │ └── verification-phone-token.blade.php │ └── partials │ └── sidebar.blade.php ├── routes ├── breadcrumbs │ ├── adminarea.php │ └── frontarea.php ├── broadcasts │ └── channels.php ├── menus │ ├── adminarea.php │ └── frontarea.php └── web │ ├── adminarea.php │ └── frontarea.php └── src ├── Console └── Commands │ ├── InstallCommand.php │ ├── MigrateCommand.php │ ├── PublishCommand.php │ ├── RollbackCommand.php │ └── SeedCommand.php ├── DataTables └── Adminarea │ ├── AbilitiesDataTable.php │ ├── AdminsDataTable.php │ ├── GuardiansDataTable.php │ ├── MembersDataTable.php │ └── RolesDataTable.php ├── Events ├── AbilityCreated.php ├── AbilityDeleted.php ├── AbilityRestored.php ├── AbilityUpdated.php ├── AdminCreated.php ├── AdminDeleted.php ├── AdminRestored.php ├── AdminUpdated.php ├── CurrentGuardLogout.php ├── GuardianCreated.php ├── GuardianDeleted.php ├── GuardianRestored.php ├── GuardianUpdated.php ├── MemberCreated.php ├── MemberDeleted.php ├── MemberRestored.php ├── MemberUpdated.php ├── RoleCreated.php ├── RoleDeleted.php ├── RoleRestored.php └── RoleUpdated.php ├── Guards └── SessionGuard.php ├── Http ├── Controllers │ ├── Adminarea │ │ ├── AbilitiesController.php │ │ ├── AccountMediaController.php │ │ ├── AccountPasswordController.php │ │ ├── AccountSessionsController.php │ │ ├── AccountSettingsController.php │ │ ├── AccountTwoFactorController.php │ │ ├── AdminsController.php │ │ ├── AdminsMediaController.php │ │ ├── AuthenticationController.php │ │ ├── EmailVerificationController.php │ │ ├── GuardiansController.php │ │ ├── MembersController.php │ │ ├── MembersMediaController.php │ │ ├── PasswordResetController.php │ │ ├── PhoneVerificationController.php │ │ ├── ReauthenticationController.php │ │ ├── RedirectionController.php │ │ └── RolesController.php │ └── Frontarea │ │ ├── AccountMediaController.php │ │ ├── AccountPasswordController.php │ │ ├── AccountSessionsController.php │ │ ├── AccountSettingsController.php │ │ ├── AccountTwoFactorController.php │ │ ├── AuthenticationController.php │ │ ├── EmailVerificationController.php │ │ ├── MemberRegistrationController.php │ │ ├── PasswordResetController.php │ │ ├── PhoneVerificationController.php │ │ ├── ReauthenticationController.php │ │ ├── RedirectionController.php │ │ └── SocialAuthenticationController.php ├── Middleware │ ├── AuthenticateSession.php │ ├── Authorize.php │ ├── Reauthenticate.php │ ├── RedirectIfAuthenticated.php │ ├── SetAuthDefaults.php │ ├── UpdateLastActivity.php │ └── UpdateTimezone.php └── Requests │ ├── Adminarea │ ├── AbilityFormProcessRequest.php │ ├── AbilityFormRequest.php │ ├── AccountPasswordRequest.php │ ├── AccountSettingsRequest.php │ ├── AccountTwoFactorPhoneRequest.php │ ├── AccountTwoFactorTotpBackupRequest.php │ ├── AccountTwoFactorTotpProcessRequest.php │ ├── AdminFormRequest.php │ ├── AuthenticationRequest.php │ ├── EmailVerificationProcessRequest.php │ ├── EmailVerificationRequest.php │ ├── EmailVerificationSendRequest.php │ ├── GuardianFormRequest.php │ ├── MemberFormRequest.php │ ├── PasswordResetPostProcessRequest.php │ ├── PasswordResetProcessRequest.php │ ├── PasswordResetRequest.php │ ├── PasswordResetSendRequest.php │ ├── PhoneVerificationProcessRequest.php │ ├── PhoneVerificationRequest.php │ ├── PhoneVerificationSendRequest.php │ ├── PhoneVerificationVerifyRequest.php │ ├── ReauthenticatePasswordFormRequest.php │ ├── RoleFormProcessRequest.php │ └── RoleFormRequest.php │ └── Frontarea │ ├── AccountPasswordRequest.php │ ├── AccountSettingsRequest.php │ ├── AccountTwoFactorPhoneRequest.php │ ├── AccountTwoFactorTotpBackupRequest.php │ ├── AccountTwoFactorTotpProcessRequest.php │ ├── AuthenticationRequest.php │ ├── EmailVerificationProcessRequest.php │ ├── EmailVerificationRequest.php │ ├── EmailVerificationSendRequest.php │ ├── MemberRegistrationProcessRequest.php │ ├── MemberRegistrationRequest.php │ ├── PasswordResetPostProcessRequest.php │ ├── PasswordResetProcessRequest.php │ ├── PasswordResetRequest.php │ ├── PasswordResetSendRequest.php │ ├── PhoneVerificationProcessRequest.php │ ├── PhoneVerificationRequest.php │ ├── PhoneVerificationSendRequest.php │ ├── PhoneVerificationVerifyRequest.php │ ├── ReauthenticatePasswordFormRequest.php │ └── SocialiteAuthenticationRequest.php ├── Listeners ├── EnforceSingleSession.php ├── LockoutThrottledLogin.php └── SendWelcomeEmail.php ├── Models ├── Ability.php ├── Admin.php ├── Guardian.php ├── Member.php ├── Role.php ├── Session.php ├── Socialite.php └── User.php ├── Notifications ├── AdminEmailVerificationNotification.php ├── AdminPasswordResetNotification.php ├── AuthenticationLockoutNotification.php ├── MemberEmailVerificationNotification.php ├── MemberPasswordResetNotification.php ├── PhoneVerificationNotification.php └── RegistrationSuccessNotification.php ├── Presenters └── AccountSidebarMenuPresenter.php ├── Providers └── AuthServiceProvider.php ├── Scopes └── UserScope.php ├── Traits └── TwoFactorAuthenticatesUsers.php └── Transformers ├── AbilityTransformer.php ├── AdminTransformer.php ├── GuardianTransformer.php ├── MemberTransformer.php └── RoleTransformer.php /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contribution Guide 2 | 3 | This project adheres to the following standards and practices. 4 | 5 | 6 | ## Versioning 7 | 8 | This project is versioned under the [Semantic Versioning](http://semver.org/) guidelines as much as possible. 9 | 10 | Releases will be numbered with the following format: 11 | 12 | - `..` 13 | - `..` 14 | 15 | And constructed with the following guidelines: 16 | 17 | - Breaking backward compatibility bumps the major and resets the minor and patch. 18 | - New additions without breaking backward compatibility bump the minor and reset the patch. 19 | - Bug fixes and misc changes bump the patch. 20 | 21 | 22 | ## Pull Requests 23 | 24 | The pull request process differs for new features and bugs. 25 | 26 | Pull requests for bugs may be sent without creating any proposal issue. If you believe that you know of a solution for a bug that has been filed, please leave a comment detailing your proposed fix or create a pull request with the fix mentioning that issue id. 27 | 28 | 29 | ## Coding Standards 30 | 31 | This project follows the FIG PHP Standards Recommendations compliant with the [PSR-1: Basic Coding Standard](http://www.php-fig.org/psr/psr-1/), [PSR-2: Coding Style Guide](http://www.php-fig.org/psr/psr-2/) and [PSR-4: Autoloader](http://www.php-fig.org/psr/psr-4/) to ensure a high level of interoperability between shared PHP code. If you notice any compliance oversights, please send a patch via pull request. 32 | 33 | 34 | ## Feature Requests 35 | 36 | If you have a proposal or a feature request, you may create an issue with `[Proposal]` in the title. 37 | 38 | The proposal should also describe the new feature, as well as implementation ideas. The proposal will then be reviewed and either approved or denied. Once a proposal is approved, a pull request may be created implementing the new feature. 39 | 40 | 41 | ## Git Flow 42 | 43 | This project follows [Git-Flow](http://nvie.com/posts/a-successful-git-branching-model/), and as such has `master` (latest stable releases), `develop` (latest WIP development) and X.Y support branches (when there's multiple major versions). 44 | 45 | Accordingly all pull requests MUST be sent to the `develop` branch. 46 | 47 | > **Note:** Pull requests which do not follow these guidelines will be closed without any further notice. 48 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016-2021, Rinvex LLC, 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Cortex Auth 2 | 3 | **Cortex Auth** is a frontend layer for the powerful authentication, authorization and verification package **rinvex/laravel-auth** on top of Laravel. It has all required controllers, views, routes, and other required assets to run a fully functional user management system with complete dashboard out of the box. 4 | 5 | [![Packagist](https://img.shields.io/packagist/v/cortex/auth.svg?label=Packagist&style=flat-square)](https://packagist.org/packages/cortex/auth) 6 | [![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/rinvex/cortex-auth.svg?label=Scrutinizer&style=flat-square)](https://scrutinizer-ci.com/g/rinvex/cortex-auth/) 7 | [![Travis](https://img.shields.io/travis/rinvex/cortex-auth.svg?label=TravisCI&style=flat-square)](https://travis-ci.org/rinvex/cortex-auth) 8 | [![StyleCI](https://styleci.io/repos/77746390/shield)](https://styleci.io/repos/77746390) 9 | [![License](https://img.shields.io/packagist/l/cortex/auth.svg?label=License&style=flat-square)](https://github.com/rinvex/cortex-auth/blob/develop/LICENSE) 10 | 11 | 12 | ## Installation and Usage 13 | 14 | This is a **[Rinvex Cortex](https://github.com/rinvex/cortex)** module, that's still not yet documented, but you can use it on your own responsibility. 15 | 16 | To be documented soon..! 17 | 18 | 19 | ## Changelog 20 | 21 | Refer to the [Changelog](CHANGELOG.md) for a full history of the project. 22 | 23 | 24 | ## Support 25 | 26 | The following support channels are available at your fingertips: 27 | 28 | - [Chat on Slack](https://bit.ly/rinvex-slack) 29 | - [Help on Email](mailto:help@rinvex.com) 30 | - [Follow on Twitter](https://twitter.com/rinvex) 31 | 32 | 33 | ## Contributing & Protocols 34 | 35 | Thank you for considering contributing to this project! The contribution guide can be found in [CONTRIBUTING.md](CONTRIBUTING.md). 36 | 37 | Bug reports, feature requests, and pull requests are very welcome. 38 | 39 | - [Versioning](CONTRIBUTING.md#versioning) 40 | - [Pull Requests](CONTRIBUTING.md#pull-requests) 41 | - [Coding Standards](CONTRIBUTING.md#coding-standards) 42 | - [Feature Requests](CONTRIBUTING.md#feature-requests) 43 | - [Git Flow](CONTRIBUTING.md#git-flow) 44 | 45 | 46 | ## Security Vulnerabilities 47 | 48 | If you discover a security vulnerability within this project, please send an e-mail to [security@rinvex.com](security@rinvex.com). All security vulnerabilities will be promptly addressed. 49 | 50 | 51 | ## About Rinvex 52 | 53 | Rinvex is a software solutions startup, specialized in integrated enterprise solutions for SMEs established in Alexandria, Egypt since June 2016. We believe that our drive The Value, The Reach, and The Impact is what differentiates us and unleash the endless possibilities of our philosophy through the power of software. We like to call it Innovation At The Speed Of Life. That’s how we do our share of advancing humanity. 54 | 55 | 56 | ## License 57 | 58 | This software is released under [The MIT License (MIT)](LICENSE). 59 | 60 | (c) 2016-2022 Rinvex LLC, Some rights reserved. 61 | -------------------------------------------------------------------------------- /database/migrations/2021_01_01_000001_create_admins_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 21 | $table->string('given_name'); 22 | $table->string('family_name')->nullable(); 23 | $table->string('email'); 24 | $table->string('username'); 25 | $table->string('password'); 26 | $table->rememberToken(); 27 | $table->timestamp('email_verified_at')->nullable(); 28 | $table->string('phone')->nullable(); 29 | $table->timestamp('phone_verified_at')->nullable(); 30 | $table->string('title')->nullable(); 31 | $table->string('organization')->nullable(); 32 | $table->string('country_code', 2)->nullable(); 33 | $table->string('language_code', 2)->nullable(); 34 | $table->string('timezone')->nullable(); 35 | $table->text('two_factor')->nullable(); 36 | $table->date('birthday')->nullable(); 37 | $table->string('gender')->nullable(); 38 | $table->schemalessAttributes('social'); 39 | $table->boolean('is_active')->default(true); 40 | $table->timestamp('last_activity')->nullable(); 41 | $table->auditableAndTimestamps(); 42 | $table->softDeletes(); 43 | 44 | // Indexes 45 | $table->unique('email'); 46 | $table->unique('username'); 47 | }); 48 | } 49 | 50 | /** 51 | * Reverse the migrations. 52 | * 53 | * @return void 54 | */ 55 | public function down(): void 56 | { 57 | Schema::dropIfExists(config('cortex.auth.tables.admins')); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /database/migrations/2021_01_01_000003_create_members_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 21 | $table->string('given_name'); 22 | $table->string('family_name')->nullable(); 23 | $table->string('email'); 24 | $table->string('username'); 25 | $table->string('password'); 26 | $table->rememberToken(); 27 | $table->timestamp('email_verified_at')->nullable(); 28 | $table->string('phone')->nullable(); 29 | $table->timestamp('phone_verified_at')->nullable(); 30 | $table->string('title')->nullable(); 31 | $table->string('organization')->nullable(); 32 | $table->string('country_code', 2)->nullable(); 33 | $table->string('language_code', 2)->nullable(); 34 | $table->string('timezone')->nullable(); 35 | $table->text('two_factor')->nullable(); 36 | $table->date('birthday')->nullable(); 37 | $table->string('gender')->nullable(); 38 | $table->schemalessAttributes('social'); 39 | $table->boolean('is_active')->default(true); 40 | $table->timestamp('last_activity')->nullable(); 41 | $table->auditableAndTimestamps(); 42 | $table->softDeletes(); 43 | }); 44 | } 45 | 46 | /** 47 | * Reverse the migrations. 48 | * 49 | * @return void 50 | */ 51 | public function down(): void 52 | { 53 | Schema::dropIfExists(config('cortex.auth.tables.members')); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /database/migrations/2021_01_01_000004_create_guardians_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 21 | $table->string('username'); 22 | $table->string('password'); 23 | $table->rememberToken(); 24 | $table->string('email'); 25 | $table->boolean('is_active')->default(true); 26 | $table->auditableAndTimestamps(); 27 | $table->softDeletes(); 28 | 29 | // Indexes 30 | $table->unique('email'); 31 | $table->unique('username'); 32 | }); 33 | } 34 | 35 | /** 36 | * Reverse the migrations. 37 | * 38 | * @return void 39 | */ 40 | public function down(): void 41 | { 42 | Schema::dropIfExists(config('cortex.auth.tables.guardians')); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /database/migrations/2021_01_01_000005_create_abilities_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 21 | $table->string('name', 150); 22 | $table->json('title')->nullable(); 23 | $table->integer('entity_id')->unsigned()->nullable(); 24 | $table->string('entity_type', 150)->nullable(); 25 | $table->boolean('only_owned')->default(false); 26 | $table->integer('scope')->nullable(); 27 | $table->auditableAndTimestamps(); 28 | 29 | // Indexes 30 | $table->index(['scope']); 31 | }); 32 | } 33 | 34 | /** 35 | * Reverse the migrations. 36 | * 37 | * @return void 38 | */ 39 | public function down() 40 | { 41 | Schema::drop(config('cortex.auth.tables.abilities')); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /database/migrations/2021_01_01_000006_create_permissions_table.php: -------------------------------------------------------------------------------- 1 | integer('ability_id')->unsigned(); 21 | $table->integer('entity_id')->unsigned(); 22 | $table->string('entity_type', 150); 23 | $table->boolean('forbidden')->default(false); 24 | $table->integer('scope')->nullable(); 25 | 26 | // Indexes 27 | $table->index(['scope']); 28 | $table->index(['ability_id']); 29 | $table->index(['entity_id', 'entity_type', 'scope'], 'permissions_entity_scope_index'); 30 | $table->foreign('ability_id')->references('id')->on(config('cortex.auth.tables.abilities')) 31 | ->onDelete('cascade')->onUpdate('cascade'); 32 | }); 33 | } 34 | 35 | /** 36 | * Reverse the migrations. 37 | * 38 | * @return void 39 | */ 40 | public function down() 41 | { 42 | Schema::drop(config('cortex.auth.tables.permissions')); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /database/migrations/2021_01_01_000007_create_roles_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 21 | $table->string('name', 150); 22 | $table->json('title')->nullable(); 23 | $table->integer('level')->unsigned()->nullable(); 24 | $table->integer('scope')->nullable(); 25 | $table->auditableAndTimestamps(); 26 | 27 | // Indexes 28 | $table->index(['scope']); 29 | $table->unique(['name', 'scope'], 'roles_name_unique'); 30 | }); 31 | } 32 | 33 | /** 34 | * Reverse the migrations. 35 | * 36 | * @return void 37 | */ 38 | public function down() 39 | { 40 | Schema::drop(config('cortex.auth.tables.roles')); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /database/migrations/2021_01_01_000008_create_assigned_roles_table.php: -------------------------------------------------------------------------------- 1 | integer('role_id')->unsigned(); 21 | $table->integer('entity_id')->unsigned(); 22 | $table->string('entity_type', 150); 23 | $table->integer('scope')->nullable(); 24 | 25 | // Indexes 26 | $table->index(['scope']); 27 | $table->index(['role_id']); 28 | $table->index(['entity_id', 'entity_type', 'scope'], 'assigned_roles_entity_index'); 29 | $table->foreign('role_id')->references('id')->on(config('cortex.auth.tables.roles')) 30 | ->onDelete('cascade')->onUpdate('cascade'); 31 | }); 32 | } 33 | 34 | /** 35 | * Reverse the migrations. 36 | * 37 | * @return void 38 | */ 39 | public function down() 40 | { 41 | Schema::drop(config('cortex.auth.tables.assigned_roles')); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /database/migrations/2021_01_01_000009_create_sessions_table.php: -------------------------------------------------------------------------------- 1 | string('id'); 21 | $table->nullableMorphs('user'); 22 | $table->string('ip_address', 45)->nullable(); 23 | $table->text('user_agent')->nullable(); 24 | $table->text('payload'); 25 | $table->integer('last_activity'); 26 | 27 | // Indexes 28 | $table->unique('id'); 29 | }); 30 | } 31 | 32 | /** 33 | * Reverse the migrations. 34 | * 35 | * @return void 36 | */ 37 | public function down(): void 38 | { 39 | Schema::dropIfExists(config('session.table')); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /database/migrations/2021_01_01_000010_create_socialites_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 21 | $table->morphs('user'); 22 | $table->string('provider'); 23 | $table->string('provider_uid'); 24 | $table->timestamps(); 25 | 26 | // Indexes 27 | $table->unique(['provider', 'provider_uid']); 28 | }); 29 | } 30 | 31 | /** 32 | * Reverse the migrations. 33 | * 34 | * @return void 35 | */ 36 | public function down(): void 37 | { 38 | Schema::dropIfExists(config('cortex.auth.tables.socialites')); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /phpstan.neon.dist: -------------------------------------------------------------------------------- 1 | includes: 2 | - ./vendor/nunomaduro/larastan/extension.neon 3 | parameters: 4 | level: 5 5 | paths: 6 | - src 7 | -------------------------------------------------------------------------------- /resources/lang/en/emails.php: -------------------------------------------------------------------------------- 1 | [ 8 | 'welcome' => [ 9 | 'subject' => 'Account Registered Successfully!', 10 | 'intro_default' => 'Your account has been successfully registered, you can login now and start using our services.', 11 | 'intro_moderation' => 'Your account has been successfully registered, you have to wait until staff approve your registration before being able to login and start using our services.', 12 | ], 13 | ], 14 | 15 | 'auth' => [ 16 | 'lockout' => [ 17 | 'subject' => 'Your Account Locked', 18 | 'intro' => 'Your account has been locked out due to too multiple failed login attempts. Failed login attempt reference: Time: :created_at, IP Address: :ip, Agent: :agent.', 19 | 'outro' => "If this wasn't you, please make sure to harden your acount security, and feel free to contact us regarding this issue.", 20 | ], 21 | ], 22 | 23 | 'passwordreset' => [ 24 | 'request' => [ 25 | 'action' => 'Reset Password', 26 | 'subject' => 'Your Password Reset Link', 27 | 'intro' => 'You are receiving this email because we received a password reset request for your account. Click the button below to reset your password (link expires in :expire):', 28 | 'outro' => 'If you did not request a password reset, no further action is required. Password reset request reference: Time: :created_at, IP Address: :ip, Agent: :agent.', 29 | ], 30 | ], 31 | 32 | 'verification' => [ 33 | 'email' => [ 34 | 'action' => 'Verify Email Address', 35 | 'subject' => 'Verify Email Address', 36 | 'intro' => "You are receiving this email because account's email requires verification. Click the button below to verify your email address (link expires in :expire):", 37 | 'outro' => 'If you believe this is sent by mistake, no further action is required. Email verification request reference: Time: :created_at, IP Address: :ip, Agent: :agent.', 38 | ], 39 | ], 40 | 41 | ]; 42 | -------------------------------------------------------------------------------- /resources/views/adminarea/pages/account-index.blade.php: -------------------------------------------------------------------------------- 1 | {{-- Master Layout --}} 2 | @extends('cortex/foundation::adminarea.layouts.default') 3 | 4 | {{-- Page Title --}} 5 | @section('title') 6 | {{ extract_title(Breadcrumbs::render()) }} 7 | @endsection 8 | 9 | {{-- Main Content --}} 10 | @section('content') 11 | 12 |
13 | 14 | {{-- Main content --}} 15 |
16 | 17 |
18 |
19 |

{{ trans('cortex/foundation::common.profile_welcome') }}

20 |

{{ trans('cortex/foundation::common.profile_welcome_body') }}

21 |
22 | 23 |
24 | 25 |
26 | 27 |
28 | 29 | @endsection 30 | -------------------------------------------------------------------------------- /resources/views/adminarea/pages/admins.blade.php: -------------------------------------------------------------------------------- 1 | {{-- Master Layout --}} 2 | @extends('cortex/foundation::adminarea.pages.datatable-index') 3 | 4 | {{-- Datatable Filters --}} 5 | @section('datatable-filters') 6 | @include('cortex/auth::adminarea.partials.datatable-filters', ['resource' => 'admins']) 7 | @endsection 8 | 9 | @push('inline-scripts') 10 | 13 | 16 | @endpush 17 | -------------------------------------------------------------------------------- /resources/views/adminarea/pages/authentication.blade.php: -------------------------------------------------------------------------------- 1 | {{-- Master Layout --}} 2 | @extends('cortex/foundation::adminarea.layouts.auth') 3 | 4 | {{-- Page Title --}} 5 | @section('title') 6 | {{ extract_title(Breadcrumbs::render()) }} 7 | @endsection 8 | 9 | {{-- Scripts --}} 10 | @push('inline-scripts') 11 | {!! JsValidator::formRequest(Cortex\Auth\Http\Requests\Adminarea\AuthenticationRequest::class)->selector('#adminarea-cortex-auth-login-form')->ignore('.skip-validation') !!} 12 | @endpush 13 | 14 | {{-- Main Content --}} 15 | @section('content') 16 | 17 | 52 | 53 | @endsection 54 | -------------------------------------------------------------------------------- /resources/views/adminarea/pages/members.blade.php: -------------------------------------------------------------------------------- 1 | {{-- Master Layout --}} 2 | @extends('cortex/foundation::adminarea.pages.datatable-index') 3 | 4 | {{-- Datatable Filters --}} 5 | @section('datatable-filters') 6 | @include('cortex/auth::adminarea.partials.datatable-filters', ['resource' => 'members']) 7 | @endsection 8 | 9 | @push('inline-scripts') 10 | 13 | 16 | @endpush 17 | -------------------------------------------------------------------------------- /resources/views/adminarea/pages/passwordreset-request.blade.php: -------------------------------------------------------------------------------- 1 | {{-- Master Layout --}} 2 | @extends('cortex/foundation::adminarea.layouts.auth') 3 | 4 | {{-- Page Title --}} 5 | @section('title') 6 | {{ extract_title(Breadcrumbs::render()) }} 7 | @endsection 8 | 9 | {{-- Scripts --}} 10 | @push('inline-scripts') 11 | {!! JsValidator::formRequest(Cortex\Auth\Http\Requests\Adminarea\PasswordResetProcessRequest::class)->selector('#adminarea-cortex-auth-passwordreset-request-form')->ignore('.skip-validation') !!} 12 | @endpush 13 | 14 | {{-- Main Content --}} 15 | @section('content') 16 | 17 | 44 | 45 | @endsection 46 | -------------------------------------------------------------------------------- /resources/views/adminarea/pages/reauthentication-password.blade.php: -------------------------------------------------------------------------------- 1 | {{-- Master Layout --}} 2 | @extends('cortex/foundation::adminarea.layouts.auth') 3 | 4 | {{-- Page Title --}} 5 | @section('title') 6 | {{ extract_title(Breadcrumbs::render()) }} 7 | @endsection 8 | 9 | {{-- Main Content --}} 10 | @section('content') 11 | 12 | 37 | 38 | @endsection 39 | -------------------------------------------------------------------------------- /resources/views/adminarea/pages/reauthentication-twofactor.blade.php: -------------------------------------------------------------------------------- 1 | {{-- Master Layout --}} 2 | @extends('cortex/foundation::adminarea.layouts.auth') 3 | 4 | {{-- Page Title --}} 5 | @section('title') 6 | {{ extract_title(Breadcrumbs::render()) }} 7 | @endsection 8 | 9 | {{-- Main Content --}} 10 | @section('content') 11 | 12 | 37 | 38 | @endsection 39 | -------------------------------------------------------------------------------- /resources/views/adminarea/pages/verification-email-request.blade.php: -------------------------------------------------------------------------------- 1 | {{-- Master Layout --}} 2 | @extends('cortex/foundation::adminarea.layouts.auth') 3 | 4 | {{-- Page Title --}} 5 | @section('title') 6 | {{ extract_title(Breadcrumbs::render()) }} 7 | @endsection 8 | 9 | {{-- Scripts --}} 10 | @push('inline-scripts') 11 | {!! JsValidator::formRequest(Cortex\Auth\Http\Requests\Adminarea\EmailVerificationSendRequest::class)->selector('#adminarea-cortex-auth-verification-email-request-form')->ignore('.skip-validation') !!} 12 | @endpush 13 | 14 | {{-- Main Content --}} 15 | @section('content') 16 | 17 | 44 | 45 | @endsection 46 | -------------------------------------------------------------------------------- /resources/views/adminarea/pages/verification-phone-token.blade.php: -------------------------------------------------------------------------------- 1 | {{-- Master Layout --}} 2 | @extends('cortex/foundation::adminarea.layouts.auth') 3 | 4 | {{-- Page Title --}} 5 | @section('title') 6 | {{ extract_title(Breadcrumbs::render()) }} 7 | @endsection 8 | 9 | {{-- Scripts --}} 10 | @push('inline-scripts') 11 | {!! JsValidator::formRequest(Cortex\Auth\Http\Requests\Adminarea\PhoneVerificationProcessRequest::class)->selector('#adminarea-cortex-auth-verification-phone-token-form')->ignore('.skip-validation') !!} 12 | @endpush 13 | 14 | {{-- Main Content --}} 15 | @section('content') 16 | 17 | 51 | 52 | @endsection 53 | -------------------------------------------------------------------------------- /resources/views/adminarea/partials/sidebar.blade.php: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 | {{ request()->user()->full_name }} 5 |
6 | @if(request()->user()->title) 7 |
8 | {{ request()->user()->title }} 9 |
10 | @endif 11 |
12 |
13 | {!! Menu::render('adminarea.cortex.auth.account.sidebar', 'account.sidebar') !!} 14 |
15 |
16 | -------------------------------------------------------------------------------- /resources/views/frontarea/pages/account-index.blade.php: -------------------------------------------------------------------------------- 1 | {{-- Master Layout --}} 2 | @extends('cortex/foundation::frontarea.layouts.default') 3 | 4 | {{-- Page Title --}} 5 | @section('title') 6 | {{ extract_title(Breadcrumbs::render()) }} 7 | @endsection 8 | 9 | {{-- Main Content --}} 10 | @section('content') 11 | 12 |
13 |
14 | 15 | {{-- Main content --}} 16 |
17 |
18 |

{{ trans('cortex/foundation::common.profile_welcome') }}

19 |

{{ trans('cortex/foundation::common.profile_welcome_body') }}

20 |
21 | 22 |
23 | 24 |
25 |
26 | 27 | @endsection 28 | -------------------------------------------------------------------------------- /resources/views/frontarea/pages/authentication.blade.php: -------------------------------------------------------------------------------- 1 | {{-- Master Layout --}} 2 | @extends('cortex/foundation::frontarea.layouts.default') 3 | 4 | {{-- Page Title --}} 5 | @section('title') 6 | {{ extract_title(Breadcrumbs::render()) }} 7 | @endsection 8 | 9 | {{-- Scripts --}} 10 | @push('inline-scripts') 11 | {!! JsValidator::formRequest(Cortex\Auth\Http\Requests\Frontarea\AuthenticationRequest::class)->selector('#frontarea-login-form')->ignore('.skip-validation') !!} 12 | @endpush 13 | 14 | @section('body-attributes')class="auth-page"@endsection 15 | 16 | {{-- Main Content --}} 17 | @section('content') 18 | 19 |
20 | 21 |
22 | 23 |
24 | 25 |
26 | 27 | {{ Form::open(['url' => route('frontarea.cortex.auth.account.login.process'), 'id' => 'frontarea-login-form', 'role' => 'auth']) }} 28 | 29 |
{{ trans('cortex/auth::common.account_login') }}
30 | 31 |
32 | {{ Form::text('loginfield', old('loginfield'), ['class' => 'form-control input-lg', 'placeholder' => trans('cortex/auth::common.loginfield'), 'required' => 'required', 'autofocus' => 'autofocus']) }} 33 | 34 | @if ($errors->has('loginfield')) 35 | {{ $errors->first('loginfield') }} 36 | @endif 37 |
38 | 39 |
40 | {{ Form::password('password', ['class' => 'form-control input-lg', 'placeholder' => trans('cortex/auth::common.password'), 'required' => 'required']) }} 41 | 42 | @if ($errors->has('password')) 43 | {{ $errors->first('password') }} 44 | @endif 45 |
46 | 47 | {{ Form::button(' '.trans('cortex/auth::common.login'), ['class' => 'btn btn-lg btn-primary btn-block', 'type' => 'submit']) }} 48 | 49 |
50 | {{ Html::link(route('frontarea.cortex.auth.account.register.member'), trans('cortex/auth::common.account_register')) }} 51 | {{ trans('cortex/foundation::common.or') }} 52 | {{ Html::link(route('frontarea.cortex.auth.account.passwordreset.request'), trans('cortex/auth::common.passwordreset')) }} 53 |
54 | 55 | {{ Form::close() }} 56 | 57 |
58 | 59 |
60 | 61 |
62 | 63 |
64 | 65 | @endsection 66 | -------------------------------------------------------------------------------- /resources/views/frontarea/pages/passwordreset-request.blade.php: -------------------------------------------------------------------------------- 1 | {{-- Master Layout --}} 2 | @extends('cortex/foundation::frontarea.layouts.default') 3 | 4 | {{-- Page Title --}} 5 | @section('title') 6 | {{ extract_title(Breadcrumbs::render()) }} 7 | @endsection 8 | 9 | {{-- Scripts --}} 10 | @push('inline-scripts') 11 | {!! JsValidator::formRequest(Cortex\Auth\Http\Requests\Frontarea\PasswordResetProcessRequest::class)->selector('#frontarea-passwordreset-request-form')->ignore('.skip-validation') !!} 12 | @endpush 13 | 14 | @section('body-attributes')class="auth-page"@endsection 15 | 16 | {{-- Main Content --}} 17 | @section('content') 18 | 19 |
20 | 21 |
22 | 23 |
24 | 25 |
26 | 27 | {{ Form::open(['url' => route('frontarea.cortex.auth.account.passwordreset.send'), 'id' => 'frontarea-passwordreset-request-form', 'role' => 'auth']) }} 28 | 29 |
{{ trans('cortex/auth::common.account_reset_password') }}
30 | 31 |
32 | {{ Form::email('email', old('email'), ['class' => 'form-control input-lg', 'placeholder' => trans('cortex/auth::common.email'), 'required' => 'required', 'autofocus' => 'autofocus']) }} 33 | 34 | @if ($errors->has('email')) 35 | {{ $errors->first('email') }} 36 | @endif 37 |
38 | 39 | {{ Form::button(' '.trans('cortex/auth::common.passwordreset_request'), ['class' => 'btn btn-lg btn-primary btn-block', 'type' => 'submit']) }} 40 | 41 |
42 | {{ Html::link(route('frontarea.cortex.auth.account.login'), trans('cortex/auth::common.account_login')) }} 43 | {{ trans('cortex/foundation::common.or') }} 44 | {{ Html::link(route('frontarea.cortex.auth.account.register.member'), trans('cortex/auth::common.account_register')) }} 45 |
46 | 47 | {{ Form::close() }} 48 | 49 |
50 | 51 |
52 | 53 |
54 | 55 |
56 | 57 | @endsection 58 | -------------------------------------------------------------------------------- /resources/views/frontarea/pages/reauthentication-password.blade.php: -------------------------------------------------------------------------------- 1 | {{-- Master Layout --}} 2 | @extends('cortex/foundation::frontarea.layouts.default') 3 | 4 | {{-- Page Title --}} 5 | @section('title') 6 | {{ extract_title(Breadcrumbs::render()) }} 7 | @endsection 8 | 9 | @section('body-attributes')class="auth-page"@endsection 10 | 11 | {{-- Main Content --}} 12 | @section('content') 13 | 14 |
15 | 16 |
17 | 18 |
19 | 20 |
21 | 22 | {{ Form::open(['url' => route('frontarea.cortex.auth.account.reauthentication.password.process'), 'id' => 'frontarea-reauthentication-form', 'role' => 'auth']) }} 23 | 24 |
{{ trans('cortex/auth::common.reauthentication.password') }}
25 | 26 |
27 | {{ Form::password('password', ['class' => 'form-control input-lg', 'placeholder' => trans('cortex/auth::common.password'), 'required' => 'required']) }} 28 | 29 | @if ($errors->has('password')) 30 | {{ $errors->first('password') }} 31 | @endif 32 |
33 | 34 | {{ Form::button(' '.trans('cortex/auth::common.login'), ['class' => 'btn btn-lg btn-primary btn-block', 'type' => 'submit']) }} 35 | 36 | {{ Form::close() }} 37 | 38 |
39 | 40 |
41 | 42 |
43 | 44 |
45 | 46 | @endsection 47 | -------------------------------------------------------------------------------- /resources/views/frontarea/pages/reauthentication-twofactor.blade.php: -------------------------------------------------------------------------------- 1 | {{-- Master Layout --}} 2 | @extends('cortex/foundation::frontarea.layouts.default') 3 | 4 | {{-- Page Title --}} 5 | @section('title') 6 | {{ extract_title(Breadcrumbs::render()) }} 7 | @endsection 8 | 9 | @section('body-attributes')class="auth-page"@endsection 10 | 11 | {{-- Main Content --}} 12 | @section('content') 13 | 14 |
15 | 16 |
17 | 18 |
19 | 20 |
21 | 22 | {{ Form::open(['url' => route('frontarea.cortex.auth.account.reauthentication.twofactor.process'), 'id' => 'frontarea-reauthentication-form', 'role' => 'auth']) }} 23 | 24 |
{{ trans('cortex/auth::common.reauthentication.twofactor') }}
25 | 26 |
27 | {{ Form::text('token', null, ['class' => 'form-control input-lg', 'placeholder' => trans('cortex/auth::common.authentication_code'), 'required' => 'required', 'autofocus' => 'autofocus']) }} 28 | 29 | @if ($errors->has('token')) 30 | {{ $errors->first('token') }} 31 | @endif 32 |
33 | 34 | {{ Form::button(' '.trans('cortex/auth::common.login'), ['class' => 'btn btn-lg btn-primary btn-block', 'type' => 'submit']) }} 35 | 36 | {{ Form::close() }} 37 | 38 |
39 | 40 |
41 | 42 |
43 | 44 |
45 | 46 | @endsection 47 | -------------------------------------------------------------------------------- /resources/views/frontarea/pages/verification-email-request.blade.php: -------------------------------------------------------------------------------- 1 | {{-- Master Layout --}} 2 | @extends('cortex/foundation::frontarea.layouts.default') 3 | 4 | {{-- Page Title --}} 5 | @section('title') 6 | {{ extract_title(Breadcrumbs::render()) }} 7 | @endsection 8 | 9 | {{-- Scripts --}} 10 | @push('inline-scripts') 11 | {!! JsValidator::formRequest(Cortex\Auth\Http\Requests\Frontarea\EmailVerificationSendRequest::class)->selector('#frontarea-verification-email-request-form')->ignore('.skip-validation') !!} 12 | @endpush 13 | 14 | @section('body-attributes')class="auth-page"@endsection 15 | 16 | {{-- Main Content --}} 17 | @section('content') 18 | 19 |
20 | 21 |
22 | 23 |
24 | 25 |
26 | 27 | {{ Form::open(['url' => route('frontarea.cortex.auth.account.verification.email.send'), 'id' => 'frontarea-verification-email-request-form', 'role' => 'auth']) }} 28 | 29 |
{{ trans('cortex/auth::common.account_verification_email') }}
30 | 31 |
32 | {{ Form::email('email', old('email', request()->user()->email ?? ''), ['class' => 'form-control input-lg', 'placeholder' => trans('cortex/auth::common.email'), 'required' => 'required', 'autofocus' => 'autofocus']) }} 33 | 34 | @if ($errors->has('email')) 35 | {{ $errors->first('email') }} 36 | @endif 37 |
38 | 39 | {{ Form::button(' '.trans('cortex/auth::common.verification_email_request'), ['class' => 'btn btn-lg btn-primary btn-block', 'type' => 'submit']) }} 40 | 41 |
42 | {{ Html::link(route('frontarea.cortex.auth.account.login'), trans('cortex/auth::common.account_login')) }} 43 | {{ trans('cortex/foundation::common.or') }} 44 | {{ Html::link(route('frontarea.cortex.auth.account.register.member'), trans('cortex/auth::common.account_register')) }} 45 |
46 | 47 | {{ Form::close() }} 48 | 49 |
50 | 51 |
52 | 53 |
54 | 55 |
56 | 57 | @endsection 58 | -------------------------------------------------------------------------------- /resources/views/frontarea/partials/sidebar.blade.php: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 | {{ request()->user()->full_name }} 5 |
6 | @if(request()->user()->title) 7 |
8 | {{ request()->user()->title }} 9 |
10 | @endif 11 |
12 |
13 | {!! Menu::render('frontarea.cortex.auth.account.sidebar', 'account.sidebar') !!} 14 |
15 |
16 | -------------------------------------------------------------------------------- /routes/broadcasts/channels.php: -------------------------------------------------------------------------------- 1 | can('list', app('cortex.auth.ability')); 9 | }); 10 | 11 | Broadcast::channel('cortex.auth.roles.index', function (Authorizable $user) { 12 | return $user->can('list', app('cortex.auth.role')); 13 | }); 14 | 15 | Broadcast::channel('cortex.auth.admins.index', function (Authorizable $user) { 16 | return $user->can('list', app('cortex.auth.admin')); 17 | }); 18 | 19 | Broadcast::channel('cortex.auth.members.index', function (Authorizable $user) { 20 | return $user->can('list', app('cortex.auth.member')); 21 | }); 22 | 23 | Broadcast::channel('cortex.auth.guardians.index', function (Authorizable $user) { 24 | return $user->can('list', app('cortex.auth.guardian')); 25 | }); 26 | -------------------------------------------------------------------------------- /routes/menus/frontarea.php: -------------------------------------------------------------------------------- 1 | user()) { 9 | Menu::register('frontarea.header.user', function (MenuGenerator $menu) use ($user) { 10 | $menu->dropdown(function (MenuItem $dropdown) { 11 | $dropdown->route(['frontarea.cortex.auth.account'], trans('cortex/auth::common.account'), null, 'fa fa-cogs'); 12 | $dropdown->route(['frontarea.cortex.auth.account.settings'], trans('cortex/auth::common.settings'), null, 'fa fa-cogs'); 13 | $dropdown->divider(); 14 | $dropdown->route(['frontarea.cortex.auth.account.logout'], trans('cortex/auth::common.logout').Form::open(['url' => route('frontarea.cortex.auth.account.logout'), 'id' => 'logout-form', 'style' => 'display: none;']).Form::close(), null, 'fa fa-sign-out', ['onclick' => "event.preventDefault(); document.getElementById('logout-form').submit();"]); 15 | }, $user->username, 10, 'fa fa-user'); 16 | }); 17 | } else { 18 | Menu::register('frontarea.header.user', function (MenuGenerator $menu) { 19 | $menu->route(['frontarea.cortex.auth.account.login'], trans('cortex/auth::common.login')); 20 | $menu->route(['frontarea.cortex.auth.account.register'], trans('cortex/auth::common.register')); 21 | }); 22 | } 23 | 24 | Menu::register('frontarea.cortex.auth.account.sidebar', function (MenuGenerator $menu) { 25 | $menu->route(['frontarea.cortex.auth.account'], trans('cortex/auth::common.account'), null, 'fa fa-user'); 26 | $menu->route(['frontarea.cortex.auth.account.settings'], trans('cortex/auth::common.settings'), null, 'fa fa-cogs'); 27 | $menu->route(['frontarea.cortex.auth.account.sessions'], trans('cortex/auth::common.sessions'), null, 'fa fa-list-alt'); 28 | $menu->route(['frontarea.cortex.auth.account.password'], trans('cortex/auth::common.password'), null, 'fa fa-key'); 29 | $menu->route(['frontarea.cortex.auth.account.twofactor'], trans('cortex/auth::common.twofactor'), null, 'fa fa-lock'); 30 | }); 31 | -------------------------------------------------------------------------------- /src/Console/Commands/InstallCommand.php: -------------------------------------------------------------------------------- 1 | alert($this->description); 35 | 36 | ! $this->option('resource') || $this->call('cortex:publish:auth', ['--force' => $this->option('force'), '--resource' => $this->option('resource')]); 37 | 38 | $this->call('cortex:migrate:auth', ['--force' => $this->option('force')]); 39 | $this->call('cortex:seed:auth'); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Console/Commands/MigrateCommand.php: -------------------------------------------------------------------------------- 1 | alert($this->description); 35 | 36 | $path = config('cortex.auth.autoload_migrations') ? 37 | realpath(__DIR__.'/../../../database/migrations') : 38 | $this->laravel->databasePath('migrations/cortex/auth'); 39 | 40 | if (file_exists($path)) { 41 | $this->call('migrate', [ 42 | '--step' => true, 43 | '--path' => $path, 44 | '--realpath' => true, 45 | '--force' => $this->option('force'), 46 | ]); 47 | } else { 48 | $this->warn('No migrations found! Consider publish them first: php artisan cortex:publish:auth'); 49 | } 50 | 51 | $this->line(''); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/Console/Commands/PublishCommand.php: -------------------------------------------------------------------------------- 1 | option('resource') ?: ['config', 'lang', 'views', 'migrations'])->each(function ($resource) { 37 | $this->call('vendor:publish', ['--tag' => "cortex/auth::$resource", '--force' => $this->option('force')]); 38 | }); 39 | 40 | $this->line(''); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/Console/Commands/RollbackCommand.php: -------------------------------------------------------------------------------- 1 | alert($this->description); 35 | 36 | $path = config('cortex.auth.autoload_migrations') ? 37 | realpath(__DIR__.'/../../../database/migrations') : 38 | $this->laravel->databasePath('migrations/cortex/auth'); 39 | 40 | if (file_exists($path)) { 41 | $this->call('migrate:reset', [ 42 | '--path' => $path, 43 | '--realpath' => true, 44 | '--force' => $this->option('force'), 45 | ]); 46 | } else { 47 | $this->warn('No migrations found! Consider publish them first: php artisan cortex:publish:auth'); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/DataTables/Adminarea/AbilitiesDataTable.php: -------------------------------------------------------------------------------- 1 | request()->user(); 33 | 34 | if ($user->isNotA('superadmin')) { 35 | $query = $query->whereIn('id', $user->getAbilities()->pluck('id')->toArray()); 36 | } 37 | 38 | return $query; 39 | } 40 | 41 | /** 42 | * Display ajax response. 43 | * 44 | * @return \Illuminate\Http\JsonResponse 45 | */ 46 | public function ajax(): JsonResponse 47 | { 48 | return datatables($this->query()) 49 | ->setTransformer(app($this->transformer)) 50 | ->orderColumn('title', 'title->"$.'.app()->getLocale().'" $1') 51 | ->whitelist(array_keys($this->getColumns())) 52 | ->make(true); 53 | } 54 | 55 | /** 56 | * Get columns. 57 | * 58 | * @return array 59 | */ 60 | protected function getColumns(): array 61 | { 62 | $link = config('cortex.foundation.route.locale_prefix') 63 | ? '"request()->segment(1).'\'})+"\">"+data+""' 64 | : '""+data+""'; 65 | 66 | return [ 67 | 'id' => ['checkboxes' => json_decode('{"selectRow": true}'), 'exportable' => false, 'printable' => false, 'width' => '1%'], 68 | 'title' => ['title' => trans('cortex/auth::common.title'), 'render' => $link, 'responsivePriority' => 0], 69 | 'name' => ['title' => trans('cortex/auth::common.name')], 70 | 'created_at' => ['title' => trans('cortex/auth::common.created_at'), 'render' => "moment(data).format('YYYY-MM-DD, hh:mm:ss A')"], 71 | 'updated_at' => ['title' => trans('cortex/auth::common.updated_at'), 'render' => "moment(data).format('YYYY-MM-DD, hh:mm:ss A')"], 72 | ]; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/DataTables/Adminarea/GuardiansDataTable.php: -------------------------------------------------------------------------------- 1 | request()->segment(1).'\'})+"\">"+data+""' 32 | : '""+data+""'; 33 | 34 | return [ 35 | 'id' => ['checkboxes' => json_decode('{"selectRow": true}'), 'exportable' => false, 'printable' => false], 36 | 'username' => ['title' => trans('cortex/auth::common.username'), 'render' => $link.'+(full.is_active ? " " : " ")', 'responsivePriority' => 0], 37 | 'email' => ['title' => trans('cortex/auth::common.email')], 38 | 'created_at' => ['title' => trans('cortex/auth::common.created_at'), 'render' => "moment(data).format('YYYY-MM-DD, hh:mm:ss A')"], 39 | 'updated_at' => ['title' => trans('cortex/auth::common.updated_at'), 'render' => "moment(data).format('YYYY-MM-DD, hh:mm:ss A')"], 40 | ]; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/DataTables/Adminarea/RolesDataTable.php: -------------------------------------------------------------------------------- 1 | request()->user(); 33 | 34 | if ($user->isNotA('superadmin')) { 35 | $query = $query->whereIn('id', $user->roles->pluck('id')->toArray()); 36 | } 37 | 38 | return $query; 39 | } 40 | 41 | /** 42 | * Display ajax response. 43 | * 44 | * @return \Illuminate\Http\JsonResponse 45 | */ 46 | public function ajax(): JsonResponse 47 | { 48 | return datatables($this->query()) 49 | ->setTransformer(app($this->transformer)) 50 | ->orderColumn('title', 'title->"$.'.app()->getLocale().'" $1') 51 | ->whitelist(array_keys($this->getColumns())) 52 | ->make(true); 53 | } 54 | 55 | /** 56 | * Get columns. 57 | * 58 | * @return array 59 | */ 60 | protected function getColumns(): array 61 | { 62 | $link = config('cortex.foundation.route.locale_prefix') 63 | ? '"request()->segment(1).'\'})+"\">"+data+""' 64 | : '""+data+""'; 65 | 66 | return [ 67 | 'id' => ['checkboxes' => json_decode('{"selectRow": true}'), 'exportable' => false, 'printable' => false], 68 | 'title' => ['title' => trans('cortex/auth::common.title'), 'render' => $link, 'responsivePriority' => 0], 69 | 'name' => ['title' => trans('cortex/auth::common.name')], 70 | 'created_at' => ['title' => trans('cortex/auth::common.created_at'), 'render' => "moment(data).format('YYYY-MM-DD, hh:mm:ss A')"], 71 | 'updated_at' => ['title' => trans('cortex/auth::common.updated_at'), 'render' => "moment(data).format('YYYY-MM-DD, hh:mm:ss A')"], 72 | ]; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/Events/AbilityCreated.php: -------------------------------------------------------------------------------- 1 | model = $ability; 42 | } 43 | 44 | /** 45 | * Get the channels the event should broadcast on. 46 | * 47 | * @return \Illuminate\Broadcasting\Channel|\Illuminate\Broadcasting\Channel[] 48 | */ 49 | public function broadcastOn() 50 | { 51 | return [ 52 | new PrivateChannel('cortex.auth.abilities.index'), 53 | ]; 54 | } 55 | 56 | /** 57 | * The event's broadcast name. 58 | * 59 | * @return string 60 | */ 61 | public function broadcastAs() 62 | { 63 | return 'ability.created'; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/Events/AbilityDeleted.php: -------------------------------------------------------------------------------- 1 | model = $ability->withoutRelations(); 40 | } 41 | 42 | /** 43 | * Get the channels the event should broadcast on. 44 | * 45 | * @return \Illuminate\Broadcasting\Channel|\Illuminate\Broadcasting\Channel[] 46 | */ 47 | public function broadcastOn() 48 | { 49 | return [ 50 | new PrivateChannel('cortex.auth.abilities.index'), 51 | new PrivateChannel("cortex.auth.abilities.{$this->model->getRouteKey()}"), 52 | ]; 53 | } 54 | 55 | /** 56 | * The event's broadcast name. 57 | * 58 | * @return string 59 | */ 60 | public function broadcastAs() 61 | { 62 | return 'ability.deleted'; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/Events/AbilityRestored.php: -------------------------------------------------------------------------------- 1 | model = $ability; 42 | } 43 | 44 | /** 45 | * Get the channels the event should broadcast on. 46 | * 47 | * @return \Illuminate\Broadcasting\Channel|\Illuminate\Broadcasting\Channel[] 48 | */ 49 | public function broadcastOn() 50 | { 51 | return [ 52 | new PrivateChannel('cortex.auth.abilities.index'), 53 | new PrivateChannel("cortex.auth.abilities.{$this->model->getRouteKey()}"), 54 | ]; 55 | } 56 | 57 | /** 58 | * The event's broadcast name. 59 | * 60 | * @return string 61 | */ 62 | public function broadcastAs() 63 | { 64 | return 'ability.restored'; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/Events/AbilityUpdated.php: -------------------------------------------------------------------------------- 1 | model = $ability; 42 | } 43 | 44 | /** 45 | * Get the channels the event should broadcast on. 46 | * 47 | * @return \Illuminate\Broadcasting\Channel|\Illuminate\Broadcasting\Channel[] 48 | */ 49 | public function broadcastOn() 50 | { 51 | return [ 52 | new PrivateChannel('cortex.auth.abilities.index'), 53 | new PrivateChannel("cortex.auth.abilities.{$this->model->getRouteKey()}"), 54 | ]; 55 | } 56 | 57 | /** 58 | * The event's broadcast name. 59 | * 60 | * @return string 61 | */ 62 | public function broadcastAs() 63 | { 64 | return 'ability.updated'; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/Events/AdminCreated.php: -------------------------------------------------------------------------------- 1 | model = $admin; 42 | } 43 | 44 | /** 45 | * Get the channels the event should broadcast on. 46 | * 47 | * @return \Illuminate\Broadcasting\Channel|\Illuminate\Broadcasting\Channel[] 48 | */ 49 | public function broadcastOn() 50 | { 51 | return [ 52 | new PrivateChannel('cortex.auth.admins.index'), 53 | ]; 54 | } 55 | 56 | /** 57 | * The event's broadcast name. 58 | * 59 | * @return string 60 | */ 61 | public function broadcastAs() 62 | { 63 | return 'admin.created'; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/Events/AdminDeleted.php: -------------------------------------------------------------------------------- 1 | model = $admin->withoutRelations(); 40 | } 41 | 42 | /** 43 | * Get the channels the event should broadcast on. 44 | * 45 | * @return \Illuminate\Broadcasting\Channel|\Illuminate\Broadcasting\Channel[] 46 | */ 47 | public function broadcastOn() 48 | { 49 | return [ 50 | new PrivateChannel('cortex.auth.admins.index'), 51 | new PrivateChannel("cortex.auth.admins.{$this->model->getRouteKey()}"), 52 | ]; 53 | } 54 | 55 | /** 56 | * The event's broadcast name. 57 | * 58 | * @return string 59 | */ 60 | public function broadcastAs() 61 | { 62 | return 'admin.deleted'; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/Events/AdminRestored.php: -------------------------------------------------------------------------------- 1 | model = $admin; 42 | } 43 | 44 | /** 45 | * Get the channels the event should broadcast on. 46 | * 47 | * @return \Illuminate\Broadcasting\Channel|\Illuminate\Broadcasting\Channel[] 48 | */ 49 | public function broadcastOn() 50 | { 51 | return [ 52 | new PrivateChannel('cortex.auth.admins.index'), 53 | new PrivateChannel("cortex.auth.admins.{$this->model->getRouteKey()}"), 54 | ]; 55 | } 56 | 57 | /** 58 | * The event's broadcast name. 59 | * 60 | * @return string 61 | */ 62 | public function broadcastAs() 63 | { 64 | return 'admin.restored'; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/Events/AdminUpdated.php: -------------------------------------------------------------------------------- 1 | model = $admin; 42 | } 43 | 44 | /** 45 | * Get the channels the event should broadcast on. 46 | * 47 | * @return \Illuminate\Broadcasting\Channel|\Illuminate\Broadcasting\Channel[] 48 | */ 49 | public function broadcastOn() 50 | { 51 | return [ 52 | new PrivateChannel('cortex.auth.admins.index'), 53 | new PrivateChannel("cortex.auth.admins.{$this->model->getRouteKey()}"), 54 | ]; 55 | } 56 | 57 | /** 58 | * The event's broadcast name. 59 | * 60 | * @return string 61 | */ 62 | public function broadcastAs() 63 | { 64 | return 'admin.updated'; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/Events/CurrentGuardLogout.php: -------------------------------------------------------------------------------- 1 | user = $user; 38 | $this->guard = $guard; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/Events/GuardianCreated.php: -------------------------------------------------------------------------------- 1 | model = $guardian; 42 | } 43 | 44 | /** 45 | * Get the channels the event should broadcast on. 46 | * 47 | * @return \Illuminate\Broadcasting\Channel|\Illuminate\Broadcasting\Channel[] 48 | */ 49 | public function broadcastOn() 50 | { 51 | return [ 52 | new PrivateChannel('cortex.auth.guardians.index'), 53 | ]; 54 | } 55 | 56 | /** 57 | * The event's broadcast name. 58 | * 59 | * @return string 60 | */ 61 | public function broadcastAs() 62 | { 63 | return 'guardian.created'; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/Events/GuardianDeleted.php: -------------------------------------------------------------------------------- 1 | model = $guardian->withoutRelations(); 40 | } 41 | 42 | /** 43 | * Get the channels the event should broadcast on. 44 | * 45 | * @return \Illuminate\Broadcasting\Channel|\Illuminate\Broadcasting\Channel[] 46 | */ 47 | public function broadcastOn() 48 | { 49 | return [ 50 | new PrivateChannel('cortex.auth.guardians.index'), 51 | new PrivateChannel("cortex.auth.guardians.{$this->model->getRouteKey()}"), 52 | ]; 53 | } 54 | 55 | /** 56 | * The event's broadcast name. 57 | * 58 | * @return string 59 | */ 60 | public function broadcastAs() 61 | { 62 | return 'guardian.deleted'; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/Events/GuardianRestored.php: -------------------------------------------------------------------------------- 1 | model = $guardian; 42 | } 43 | 44 | /** 45 | * Get the channels the event should broadcast on. 46 | * 47 | * @return \Illuminate\Broadcasting\Channel|\Illuminate\Broadcasting\Channel[] 48 | */ 49 | public function broadcastOn() 50 | { 51 | return [ 52 | new PrivateChannel('cortex.auth.guardians.index'), 53 | new PrivateChannel("cortex.auth.guardians.{$this->model->getRouteKey()}"), 54 | ]; 55 | } 56 | 57 | /** 58 | * The event's broadcast name. 59 | * 60 | * @return string 61 | */ 62 | public function broadcastAs() 63 | { 64 | return 'guardian.restored'; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/Events/GuardianUpdated.php: -------------------------------------------------------------------------------- 1 | model = $guardian; 42 | } 43 | 44 | /** 45 | * Get the channels the event should broadcast on. 46 | * 47 | * @return \Illuminate\Broadcasting\Channel|\Illuminate\Broadcasting\Channel[] 48 | */ 49 | public function broadcastOn() 50 | { 51 | return [ 52 | new PrivateChannel('cortex.auth.guardians.index'), 53 | new PrivateChannel("cortex.auth.guardians.{$this->model->getRouteKey()}"), 54 | ]; 55 | } 56 | 57 | /** 58 | * The event's broadcast name. 59 | * 60 | * @return string 61 | */ 62 | public function broadcastAs() 63 | { 64 | return 'guardian.updated'; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/Events/MemberCreated.php: -------------------------------------------------------------------------------- 1 | model = $member; 42 | } 43 | 44 | /** 45 | * Get the channels the event should broadcast on. 46 | * 47 | * @return \Illuminate\Broadcasting\Channel|\Illuminate\Broadcasting\Channel[] 48 | */ 49 | public function broadcastOn() 50 | { 51 | return [ 52 | new PrivateChannel('cortex.auth.members.index'), 53 | ]; 54 | } 55 | 56 | /** 57 | * The event's broadcast name. 58 | * 59 | * @return string 60 | */ 61 | public function broadcastAs() 62 | { 63 | return 'member.created'; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/Events/MemberDeleted.php: -------------------------------------------------------------------------------- 1 | model = $member->withoutRelations(); 40 | } 41 | 42 | /** 43 | * Get the channels the event should broadcast on. 44 | * 45 | * @return \Illuminate\Broadcasting\Channel|\Illuminate\Broadcasting\Channel[] 46 | */ 47 | public function broadcastOn() 48 | { 49 | return [ 50 | new PrivateChannel('cortex.auth.members.index'), 51 | new PrivateChannel("cortex.auth.members.{$this->model->getRouteKey()}"), 52 | ]; 53 | } 54 | 55 | /** 56 | * The event's broadcast name. 57 | * 58 | * @return string 59 | */ 60 | public function broadcastAs() 61 | { 62 | return 'member.deleted'; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/Events/MemberRestored.php: -------------------------------------------------------------------------------- 1 | model = $member; 42 | } 43 | 44 | /** 45 | * Get the channels the event should broadcast on. 46 | * 47 | * @return \Illuminate\Broadcasting\Channel|\Illuminate\Broadcasting\Channel[] 48 | */ 49 | public function broadcastOn() 50 | { 51 | return [ 52 | new PrivateChannel('cortex.auth.members.index'), 53 | new PrivateChannel("cortex.auth.members.{$this->model->getRouteKey()}"), 54 | ]; 55 | } 56 | 57 | /** 58 | * The event's broadcast name. 59 | * 60 | * @return string 61 | */ 62 | public function broadcastAs() 63 | { 64 | return 'member.restored'; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/Events/MemberUpdated.php: -------------------------------------------------------------------------------- 1 | model = $member; 42 | } 43 | 44 | /** 45 | * Get the channels the event should broadcast on. 46 | * 47 | * @return \Illuminate\Broadcasting\Channel|\Illuminate\Broadcasting\Channel[] 48 | */ 49 | public function broadcastOn() 50 | { 51 | return [ 52 | new PrivateChannel('cortex.auth.members.index'), 53 | new PrivateChannel("cortex.auth.members.{$this->model->getRouteKey()}"), 54 | ]; 55 | } 56 | 57 | /** 58 | * The event's broadcast name. 59 | * 60 | * @return string 61 | */ 62 | public function broadcastAs() 63 | { 64 | return 'member.updated'; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/Events/RoleCreated.php: -------------------------------------------------------------------------------- 1 | model = $role; 42 | } 43 | 44 | /** 45 | * Get the channels the event should broadcast on. 46 | * 47 | * @return \Illuminate\Broadcasting\Channel|\Illuminate\Broadcasting\Channel[] 48 | */ 49 | public function broadcastOn() 50 | { 51 | return [ 52 | new PrivateChannel('cortex.auth.roles.index'), 53 | ]; 54 | } 55 | 56 | /** 57 | * The event's broadcast name. 58 | * 59 | * @return string 60 | */ 61 | public function broadcastAs() 62 | { 63 | return 'role.created'; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/Events/RoleDeleted.php: -------------------------------------------------------------------------------- 1 | model = $role->withoutRelations(); 40 | } 41 | 42 | /** 43 | * Get the channels the event should broadcast on. 44 | * 45 | * @return \Illuminate\Broadcasting\Channel|\Illuminate\Broadcasting\Channel[] 46 | */ 47 | public function broadcastOn() 48 | { 49 | return [ 50 | new PrivateChannel('cortex.auth.roles.index'), 51 | new PrivateChannel("cortex.auth.roles.{$this->model->getRouteKey()}"), 52 | ]; 53 | } 54 | 55 | /** 56 | * The event's broadcast name. 57 | * 58 | * @return string 59 | */ 60 | public function broadcastAs() 61 | { 62 | return 'role.deleted'; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/Events/RoleRestored.php: -------------------------------------------------------------------------------- 1 | model = $role; 42 | } 43 | 44 | /** 45 | * Get the channels the event should broadcast on. 46 | * 47 | * @return \Illuminate\Broadcasting\Channel|\Illuminate\Broadcasting\Channel[] 48 | */ 49 | public function broadcastOn() 50 | { 51 | return [ 52 | new PrivateChannel('cortex.auth.roles.index'), 53 | new PrivateChannel("cortex.auth.roles.{$this->model->getRouteKey()}"), 54 | ]; 55 | } 56 | 57 | /** 58 | * The event's broadcast name. 59 | * 60 | * @return string 61 | */ 62 | public function broadcastAs() 63 | { 64 | return 'role.restored'; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/Events/RoleUpdated.php: -------------------------------------------------------------------------------- 1 | model = $role; 42 | } 43 | 44 | /** 45 | * Get the channels the event should broadcast on. 46 | * 47 | * @return \Illuminate\Broadcasting\Channel|\Illuminate\Broadcasting\Channel[] 48 | */ 49 | public function broadcastOn() 50 | { 51 | return [ 52 | new PrivateChannel('cortex.auth.roles.index'), 53 | new PrivateChannel("cortex.auth.roles.{$this->model->getRouteKey()}"), 54 | ]; 55 | } 56 | 57 | /** 58 | * The event's broadcast name. 59 | * 60 | * @return string 61 | */ 62 | public function broadcastAs() 63 | { 64 | return 'role.updated'; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/Guards/SessionGuard.php: -------------------------------------------------------------------------------- 1 | name.'_'.$this->getSession()->getSha1().'.login'; 19 | } 20 | 21 | /** 22 | * Get the name of the cookie used to store the "recaller". 23 | * 24 | * @return string 25 | */ 26 | public function getRecallerName() 27 | { 28 | return $this->name.'_'.$this->getSession()->getSha1().'.remember'; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Http/Controllers/Adminarea/AccountMediaController.php: -------------------------------------------------------------------------------- 1 | media()->where($media->getKeyName(), $media->getKey())->first()->delete(); 24 | 25 | return intend([ 26 | 'url' => route('adminarea.cortex.auth.account.settings'), 27 | 'with' => ['warning' => trans('cortex/foundation::messages.resource_deleted', ['resource' => trans('cortex/foundation::common.media'), 'identifier' => $media->getRouteKey()])], 28 | ]); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Http/Controllers/Adminarea/AccountPasswordController.php: -------------------------------------------------------------------------------- 1 | user()->fill(['password' => $request->input('new_password')])->forceSave(); 33 | 34 | return intend([ 35 | 'back' => true, 36 | 'with' => ['success' => trans('cortex/auth::messages.account.updated_password')], 37 | ]); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Http/Controllers/Adminarea/AccountSessionsController.php: -------------------------------------------------------------------------------- 1 | delete(); 35 | 36 | return intend([ 37 | 'back' => true, 38 | 'with' => ['warning' => trans('cortex/foundation::messages.resource_deleted', ['resource' => trans('cortex/auth::common.session'), 'identifier' => $session->getRouteKey()])], 39 | ]); 40 | } 41 | 42 | /** 43 | * Flush all sessions. 44 | * 45 | * @param \Illuminate\Http\Request $request 46 | * 47 | * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse 48 | */ 49 | public function flush(Request $request) 50 | { 51 | $request->user()->logoutOtherDevices(); 52 | 53 | return intend([ 54 | 'back' => true, 55 | 'with' => ['warning' => trans('cortex/auth::messages.auth.session.flushed')], 56 | ]); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/Http/Controllers/Adminarea/AdminsMediaController.php: -------------------------------------------------------------------------------- 1 | mapResourceAbilities() as $method => $ability) { 28 | $modelName = in_array($method, $this->resourceMethodsWithoutModels()) ? $model : $parameter; 29 | 30 | $middleware["can:update,$modelName"][] = $method; 31 | $middleware["can:$ability,media"][] = $method; 32 | } 33 | 34 | foreach ($middleware as $middlewareName => $methods) { 35 | $this->middleware($middlewareName, $options)->only($methods); 36 | } 37 | } 38 | 39 | /** 40 | * Destroy given admin media. 41 | * 42 | * @param \Cortex\Auth\Models\Admin $admin 43 | * @param \Cortex\Foundation\Models\Media $media 44 | * 45 | * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse 46 | */ 47 | public function destroy(Admin $admin, Media $media) 48 | { 49 | $admin->media()->where($media->getKeyName(), $media->getKey())->first()->delete(); 50 | 51 | return intend([ 52 | 'url' => route('adminarea.cortex.auth.admins.edit', ['admin' => $admin]), 53 | 'with' => ['warning' => trans('cortex/foundation::messages.resource_deleted', ['resource' => trans('cortex/foundation::common.media'), 'identifier' => $media->getRouteKey()])], 54 | ]); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/Http/Controllers/Adminarea/MembersMediaController.php: -------------------------------------------------------------------------------- 1 | mapResourceAbilities() as $method => $ability) { 28 | $modelName = in_array($method, $this->resourceMethodsWithoutModels()) ? $model : $parameter; 29 | 30 | $middleware["can:update,$modelName"][] = $method; 31 | $middleware["can:$ability,media"][] = $method; 32 | } 33 | 34 | foreach ($middleware as $middlewareName => $methods) { 35 | $this->middleware($middlewareName, $options)->only($methods); 36 | } 37 | } 38 | 39 | /** 40 | * Destroy given member media. 41 | * 42 | * @param \Cortex\Auth\Models\Member $member 43 | * @param \Cortex\Foundation\Models\Media $media 44 | * 45 | * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse 46 | */ 47 | public function destroy(Member $member, Media $media) 48 | { 49 | $member->media()->where($media->getKeyName(), $media->getKey())->first()->delete(); 50 | 51 | return intend([ 52 | 'url' => route('adminarea.cortex.auth.members.edit', ['member' => $member]), 53 | 'with' => ['warning' => trans('cortex/foundation::messages.resource_deleted', ['resource' => trans('cortex/foundation::common.media'), 'identifier' => $media->getRouteKey()])], 54 | ]); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/Http/Controllers/Adminarea/ReauthenticationController.php: -------------------------------------------------------------------------------- 1 | resetSessionConfirmationTimeout($request, 'password'); 36 | 37 | return intend([ 38 | 'intended' => url(route('adminarea.home')), 39 | ]); 40 | } 41 | 42 | /** 43 | * @param Request $request 44 | * 45 | * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse 46 | */ 47 | public function processTwofactor(Request $request) 48 | { 49 | $user = $request->user(); 50 | $token = (int) $request->input('token'); 51 | 52 | if ($this->attemptTwoFactor($user, $token)) { 53 | $this->resetSessionConfirmationTimeout($request, 'twofactor'); 54 | 55 | return intend([ 56 | 'intended' => route('adminarea.home'), 57 | ]); 58 | } 59 | 60 | return intend([ 61 | 'intended' => route('adminarea.home'), 62 | 'withErrors' => ['token' => trans('cortex/auth::messages.verification.twofactor.invalid_token')], 63 | ]); 64 | } 65 | 66 | /** 67 | * Reset the session confirmation timeout. 68 | * 69 | * @param \Illuminate\Http\Request $request 70 | * @param string $type 71 | * 72 | * @return void 73 | */ 74 | protected function resetSessionConfirmationTimeout(Request $request, string $type = 'password'): void 75 | { 76 | $request->session()->put("auth.{$type}_confirmed_at", time()); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/Http/Controllers/Adminarea/RedirectionController.php: -------------------------------------------------------------------------------- 1 | route('adminarea.cortex.auth.account.passwordreset.request'), 20 | ]); 21 | } 22 | 23 | /** 24 | * Redirect to homepage. 25 | * 26 | * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse 27 | */ 28 | public function verification() 29 | { 30 | return intend([ 31 | 'url' => route('adminarea.home'), 32 | ]); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Http/Controllers/Frontarea/AccountMediaController.php: -------------------------------------------------------------------------------- 1 | media()->where($media->getKeyName(), $media->getKey())->first()->delete(); 26 | 27 | return intend([ 28 | 'url' => route('frontarea.cortex.auth.account.settings'), 29 | 'with' => ['warning' => trans('cortex/foundation::messages.resource_deleted', ['resource' => trans('cortex/foundation::common.media'), 'identifier' => $media->getRouteKey()])], 30 | ]); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Http/Controllers/Frontarea/AccountPasswordController.php: -------------------------------------------------------------------------------- 1 | user()->fill(['password' => $request->input('new_password')])->forceSave(); 33 | 34 | return intend([ 35 | 'back' => true, 36 | 'with' => ['success' => trans('cortex/auth::messages.account.updated_password')], 37 | ]); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Http/Controllers/Frontarea/AccountSessionsController.php: -------------------------------------------------------------------------------- 1 | delete(); 37 | 38 | return intend([ 39 | 'back' => true, 40 | 'with' => ['warning' => trans('cortex/foundation::messages.resource_deleted', ['resource' => trans('cortex/auth::common.session'), 'identifier' => $session->getRouteKey()])], 41 | ]); 42 | } 43 | 44 | /** 45 | * Flush all sessions. 46 | * 47 | * @param \Illuminate\Http\Request $request 48 | * 49 | * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse 50 | */ 51 | public function flush(Request $request) 52 | { 53 | $request->user()->logoutOtherDevices(); 54 | 55 | return intend([ 56 | 'back' => true, 57 | 'with' => ['warning' => trans('cortex/auth::messages.auth.session.flushed')], 58 | ]); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/Http/Controllers/Frontarea/MemberRegistrationController.php: -------------------------------------------------------------------------------- 1 | validated(); 39 | 40 | $member->fill($data)->save(); 41 | 42 | // Fire the register success event 43 | event(new Registered($member)); 44 | 45 | // Send verification if required 46 | ! config('cortex.auth.emails.verification') 47 | || app('rinvex.auth.emailverification')->broker($request->emailVerificationBroker())->sendVerificationLink(['email' => $member->email]); 48 | 49 | // Auto-login registered member 50 | auth()->login($member); 51 | 52 | // Registration completed successfully 53 | return intend([ 54 | 'intended' => route('frontarea.home'), 55 | 'with' => ['success' => trans('cortex/auth::messages.register.success')], 56 | ]); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/Http/Controllers/Frontarea/ReauthenticationController.php: -------------------------------------------------------------------------------- 1 | resetSessionConfirmationTimeout($request, 'password'); 36 | 37 | return intend([ 38 | 'intended' => url(route('frontarea.home')), 39 | ]); 40 | } 41 | 42 | /** 43 | * @param Request $request 44 | * 45 | * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse 46 | */ 47 | public function processTwofactor(Request $request) 48 | { 49 | $user = $request->user(); 50 | $token = (int) $request->input('token'); 51 | 52 | if ($this->attemptTwoFactor($user, $token)) { 53 | $this->resetSessionConfirmationTimeout($request, 'twofactor'); 54 | 55 | return intend([ 56 | 'intended' => url(route('frontarea.home')), 57 | ]); 58 | } 59 | 60 | return intend([ 61 | 'intended' => url(route('frontarea.home')), 62 | 'withErrors' => ['token' => trans('cortex/auth::messages.verification.twofactor.invalid_token')], 63 | ]); 64 | } 65 | 66 | /** 67 | * Reset the session confirmation timeout. 68 | * 69 | * @param \Illuminate\Http\Request $request 70 | * @param string $type 71 | * 72 | * @return void 73 | */ 74 | protected function resetSessionConfirmationTimeout(Request $request, string $type = 'password'): void 75 | { 76 | $request->session()->put("auth.{$type}_confirmed_at", time()); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/Http/Controllers/Frontarea/RedirectionController.php: -------------------------------------------------------------------------------- 1 | route('frontarea.cortex.auth.account.passwordreset.request'), 20 | ]); 21 | } 22 | 23 | /** 24 | * Redirect to member registration. 25 | * 26 | * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse 27 | */ 28 | public function registration() 29 | { 30 | return intend([ 31 | 'url' => route('frontarea.cortex.auth.account.register.member'), 32 | ]); 33 | } 34 | 35 | /** 36 | * Redirect to homepage. 37 | * 38 | * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse 39 | */ 40 | public function verification() 41 | { 42 | return intend([ 43 | 'url' => route('frontarea.home'), 44 | ]); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/Http/Middleware/AuthenticateSession.php: -------------------------------------------------------------------------------- 1 | hasSession() || ! $request->user()) { 28 | return $next($request); 29 | } 30 | 31 | if ($this->auth->viaRemember()) { 32 | $passwordHash = explode('|', $request->cookies->get($this->auth->getRecallerName()))[2] ?? null; 33 | 34 | if (! $passwordHash || $passwordHash !== $request->user()->getAuthPassword()) { 35 | $this->logout($request); 36 | } 37 | } 38 | 39 | if (! $request->session()->has($passwordHashKey)) { 40 | $this->storePasswordHashInSessionPerGuard($request, $passwordHashKey); 41 | } 42 | 43 | if ($request->session()->get($passwordHashKey) !== $request->user()->getAuthPassword()) { 44 | $this->logout($request); 45 | } 46 | 47 | return tap($next($request), function () use ($request, $passwordHashKey) { 48 | if (! is_null($this->auth->user())) { 49 | $this->storePasswordHashInSessionPerGuard($request, $passwordHashKey); 50 | } 51 | }); 52 | } 53 | 54 | /** 55 | * Store the user's current password hash in the session. 56 | * 57 | * @param \Illuminate\Http\Request $request 58 | * @param string $passwordHashKey 59 | * 60 | * @return void 61 | */ 62 | protected function storePasswordHashInSessionPerGuard($request, $passwordHashKey) 63 | { 64 | if (! $request->user()) { 65 | return; 66 | } 67 | 68 | $request->session()->put([ 69 | $passwordHashKey => $request->user()->getAuthPassword(), 70 | ]); 71 | } 72 | 73 | /** 74 | * Log the user out of the application. 75 | * 76 | * @param \Illuminate\Http\Request $request 77 | * 78 | * @throws \Illuminate\Auth\AuthenticationException 79 | * 80 | * @return void 81 | */ 82 | protected function logout($request) 83 | { 84 | $this->auth->logoutCurrentGuard(); 85 | 86 | throw new AuthenticationException('Unauthenticated.', [$this->auth->getDefaultDriver()]); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/Http/Middleware/Authorize.php: -------------------------------------------------------------------------------- 1 | isApi() && $request->user()) { 28 | $this->gate->forUser($request->user()->token())->authorize($ability, $this->getGateArguments($request, $models)); 29 | } else { 30 | $this->gate->authorize($ability, $this->getGateArguments($request, $models)); 31 | } 32 | 33 | return $next($request); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Http/Middleware/Reauthenticate.php: -------------------------------------------------------------------------------- 1 | responseFactory = $responseFactory; 38 | $this->urlGenerator = $urlGenerator; 39 | } 40 | 41 | /** 42 | * Handle an incoming request. 43 | * 44 | * @param \Illuminate\Http\Request $request 45 | * @param \Closure $next 46 | * @param string $type 47 | * @param int $timeout 48 | * @param bool $renew 49 | * 50 | * @return mixed 51 | */ 52 | public function handle($request, Closure $next, string $type = 'password', int $timeout = null, bool $renew = false) 53 | { 54 | if ($this->shouldConfirmSession($request, $type, $timeout)) { 55 | if ($request->expectsJson()) { 56 | return $this->responseFactory->json([ 57 | 'message' => trans('cortex/auth::common.password_required'), 58 | ], 423); 59 | } 60 | 61 | return $this->responseFactory->redirectGuest( 62 | $this->urlGenerator->route($request->accessarea().'.reauthentication.'.$type) 63 | ); 64 | } 65 | 66 | ! $renew || $request->session()->put("auth.{$type}_confirmed_at", time()); 67 | 68 | return $next($request); 69 | } 70 | 71 | /** 72 | * Determine if the confirmation timeout has expired. 73 | * 74 | * @param \Illuminate\Http\Request $request 75 | * @param string $type 76 | * @param int|null $timeout 77 | * 78 | * @return bool 79 | */ 80 | protected function shouldConfirmSession($request, string $type = 'password', int $timeout = null) 81 | { 82 | $confirmedAt = time() - $request->session()->get("auth.{$type}_confirmed_at", 0); 83 | 84 | return $confirmedAt > config("auth.{$type}_timeout", $timeout ?? 10800); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/Http/Middleware/RedirectIfAuthenticated.php: -------------------------------------------------------------------------------- 1 | check()) { 28 | return intend([ 29 | 'url' => route($request->accessarea().'.home'), 30 | 'with' => ['success' => trans('cortex/auth::messages.authenticated')], 31 | ]); 32 | } 33 | } 34 | 35 | return $next($request); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Http/Middleware/SetAuthDefaults.php: -------------------------------------------------------------------------------- 1 | guard()) { 23 | // It's better to set auth defaults config globally, 24 | // instead of using `auth()->shouldUse($guard);` 25 | config()->set('auth.defaults.guard', $guard); 26 | config()->set('auth.defaults.apiguard', $guard); 27 | config()->set('auth.defaults.provider', Str::afterLast(Str::plural($guard), ':')); 28 | config()->set('auth.defaults.passwords', $guard); 29 | config()->set('auth.defaults.emails', $guard); 30 | } 31 | 32 | return $next($request); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Http/Middleware/UpdateLastActivity.php: -------------------------------------------------------------------------------- 1 | user()) { 36 | // Skip timestamps update 37 | $user->timestamps = false; 38 | 39 | // Update last activity with a fresh timestamp 40 | $user->last_activity = $user->freshTimestamp(); 41 | 42 | // Skip events trigger & model validation 43 | $user->saveQuietly(); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/Http/Middleware/UpdateTimezone.php: -------------------------------------------------------------------------------- 1 | ajax() && $user = $request->user()) { 22 | $timezone = geoip($request->getClientIp())->timezone; 23 | 24 | if (! $user->timezone) { 25 | // We are using database queries rather than eloquent, to bypass triggering events. 26 | // Triggering update events flush cache and costs us more queries, which we don't need. 27 | // This is also to skip model validation, in case there's other invalid fields in the model! 28 | $user->newQuery()->where($user->getKeyName(), $user->getKey())->update(['timezone' => $timezone]); 29 | $request->session()->flash('success', trans('cortex/auth::messages.account.updated_timezone', ['timezone' => $timezone])); 30 | } 31 | } 32 | 33 | return $next($request); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Http/Requests/Adminarea/AbilityFormProcessRequest.php: -------------------------------------------------------------------------------- 1 | all(); 17 | 18 | // Set roles 19 | if (! empty($data['roles'])) { 20 | if ($data['roles'] && $this->user()->can('grant', app('cortex.auth.ability'))) { 21 | $roles = array_map('intval', $this->get('roles', [])); 22 | $data['roles'] = $this->user()->isA('superadmin') ? $roles 23 | : $this->user()->roles->pluck('id')->intersect($roles)->toArray(); 24 | } else { 25 | unset($data['roles']); 26 | } 27 | } 28 | 29 | $this->replace($data); 30 | } 31 | 32 | /** 33 | * Get the validation rules that apply to the request. 34 | * 35 | * @return array 36 | */ 37 | public function rules(): array 38 | { 39 | $user = $this->route('ability') ?? app('cortex.auth.ability'); 40 | $user->updateRulesUniques(); 41 | $rules = $user->getRules(); 42 | $rules['roles'] = 'nullable|array'; 43 | 44 | return $rules; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/Http/Requests/Adminarea/AbilityFormRequest.php: -------------------------------------------------------------------------------- 1 | user()->isA('superadmin') && ! $this->user()->getAbilities()->contains($this->route('ability'))) { 25 | throw new GenericException(trans('cortex/auth::messages.unauthorized'), route('adminarea.cortex.auth.abilities.index'), null, 403); 26 | } 27 | 28 | return true; 29 | } 30 | 31 | /** 32 | * Get the validation rules that apply to the request. 33 | * 34 | * @return array 35 | */ 36 | public function rules(): array 37 | { 38 | return []; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/Http/Requests/Adminarea/AccountPasswordRequest.php: -------------------------------------------------------------------------------- 1 | after(function ($validator) { 33 | if (! auth()->getProvider()->validateCredentials($this->user(), ['password' => $this->get('old_password')])) { 34 | $validator->errors()->add('old_password', trans('cortex/auth::messages.account.wrong_password')); 35 | } 36 | 37 | if (auth()->getProvider()->validateCredentials($this->user(), ['password' => $this->get('new_password')])) { 38 | $validator->errors()->add('new_password', trans('cortex/auth::messages.account.different_password')); 39 | } 40 | }); 41 | } 42 | 43 | /** 44 | * Get the validation rules that apply to the request. 45 | * 46 | * @return array 47 | */ 48 | public function rules(): array 49 | { 50 | return [ 51 | 'old_password' => ['required', config('validation.rules.password')], 52 | 'new_password' => ['required', 'confirmed', config('validation.rules.password')], 53 | ]; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/Http/Requests/Adminarea/AccountSettingsRequest.php: -------------------------------------------------------------------------------- 1 | all(); 33 | 34 | $resetTwoFactor = false; 35 | $country = $data['country_code'] ?? null; 36 | $email = $data['email'] ?? null; 37 | $phone = $data['phone'] ?? null; 38 | $user = $this->user(); 39 | $twoFactor = $user->getTwoFactor(); 40 | 41 | if ($email !== $user->email) { 42 | $resetTwoFactor = true; 43 | } 44 | 45 | if ($phone !== $user->phone || $country !== $user->country_code) { 46 | $resetTwoFactor = true; 47 | } 48 | 49 | if ($twoFactor || $resetTwoFactor) { 50 | $data['phone_verified_at'] = null; 51 | Arr::set($twoFactor, 'phone.enabled', false); 52 | $data['two_factor'] = $twoFactor; 53 | } 54 | 55 | $this->replace($data); 56 | } 57 | 58 | /** 59 | * Get the validation rules that apply to the request. 60 | * 61 | * @return array 62 | */ 63 | public function rules(): array 64 | { 65 | $mediaSize = config('cortex.foundation.media.size'); 66 | $mediaMimetypes = config('cortex.foundation.media.mimetypes'); 67 | 68 | $user = $this->user(); 69 | $user->updateRulesUniques(); 70 | $rules = $user->getRules(); 71 | 72 | $rules['profile_picture'] = 'nullable|mimetypes:'.$mediaMimetypes.'|max:'.$mediaSize; 73 | $rules['cover_photo'] = 'nullable|mimetypes:'.$mediaMimetypes.'|max:'.$mediaSize; 74 | 75 | return $rules; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/Http/Requests/Adminarea/AccountTwoFactorPhoneRequest.php: -------------------------------------------------------------------------------- 1 | user(); 33 | 34 | $validator->after(function ($validator) use ($user) { 35 | if (! $user->phone || ! $user->hasVerifiedPhone()) { 36 | $validator->errors()->add('phone', trans('cortex/auth::messages.account.'.(! $user->phone ? 'phone_field_required' : 'phone_verification_required'))); 37 | } 38 | }); 39 | } 40 | 41 | /** 42 | * Get the validation rules that apply to the request. 43 | * 44 | * @return array 45 | */ 46 | public function rules(): array 47 | { 48 | return []; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/Http/Requests/Adminarea/AccountTwoFactorTotpBackupRequest.php: -------------------------------------------------------------------------------- 1 | user()->getTwoFactor(); 22 | 23 | if (! $twoFactor['totp']['enabled']) { 24 | throw new GenericException(trans('cortex/auth::messages.verification.twofactor.totp.cant_backup'), route('adminarea.cortex.auth.account.settings')); 25 | } 26 | 27 | return true; 28 | } 29 | 30 | /** 31 | * Get the validation rules that apply to the request. 32 | * 33 | * @return array 34 | */ 35 | public function rules(): array 36 | { 37 | return []; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Http/Requests/Adminarea/AccountTwoFactorTotpProcessRequest.php: -------------------------------------------------------------------------------- 1 | 'required|digits:6', 32 | ]; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Http/Requests/Adminarea/AuthenticationRequest.php: -------------------------------------------------------------------------------- 1 | 'required|min:3|max:128', 30 | 'password' => ['required', config('validation.rules.password')], 31 | ]; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Http/Requests/Adminarea/EmailVerificationProcessRequest.php: -------------------------------------------------------------------------------- 1 | 'required|regex:/^([0-9a-f]*)$/', 20 | 'email' => ['required', ...config('validation.rules.email'), 'exists:'.config('cortex.auth.models.admin').',email'], 21 | ]; 22 | } 23 | 24 | /** 25 | * {@inheritdoc} 26 | */ 27 | protected function getRedirectUrl() 28 | { 29 | return $this->redirector->getUrlGenerator()->route('adminarea.cortex.auth.account.verification.email.request'); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Http/Requests/Adminarea/EmailVerificationRequest.php: -------------------------------------------------------------------------------- 1 | user()) && $user->hasVerifiedEmail()) { 23 | throw new GenericException(trans('cortex/auth::messages.verification.email.already_verified'), route('adminarea.cortex.auth.account.settings')); 24 | } 25 | 26 | return true; 27 | } 28 | 29 | /** 30 | * Get the validation rules that apply to the request. 31 | * 32 | * @return array 33 | */ 34 | public function rules(): array 35 | { 36 | return []; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Http/Requests/Adminarea/EmailVerificationSendRequest.php: -------------------------------------------------------------------------------- 1 | ['required', ...config('validation.rules.email'), 'exists:'.config('cortex.auth.models.admin').',email'], 18 | ]; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Http/Requests/Adminarea/GuardianFormRequest.php: -------------------------------------------------------------------------------- 1 | all(); 32 | 33 | $guardian = $this->route('guardian') ?? app('cortex.auth.guardian'); 34 | 35 | if ($guardian->exists && empty($data['password'])) { 36 | unset($data['password'], $data['password_confirmation']); 37 | } 38 | 39 | $this->replace($data); 40 | } 41 | 42 | /** 43 | * Get the validation rules that apply to the request. 44 | * 45 | * @return array 46 | */ 47 | public function rules(): array 48 | { 49 | $guardian = $this->route('guardian') ?? app('cortex.auth.guardian'); 50 | $guardian->updateRulesUniques(); 51 | $rules = $guardian->getRules(); 52 | 53 | $rules['password'][] = 'confirmed'; 54 | 55 | return $rules; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/Http/Requests/Adminarea/MemberFormRequest.php: -------------------------------------------------------------------------------- 1 | all(); 33 | 34 | $member = $this->route('member') ?? app('cortex.auth.member'); 35 | $country = $data['country_code'] ?? null; 36 | $twoFactor = $member->getTwoFactor(); 37 | 38 | if ($member->exists && empty($data['password'])) { 39 | unset($data['password'], $data['password_confirmation']); 40 | } 41 | 42 | // Set abilities 43 | if (! empty($data['abilities'])) { 44 | if ($this->user()->can('grant', app('cortex.auth.ability'))) { 45 | $abilities = array_map('intval', $this->get('abilities', [])); 46 | $data['abilities'] = $this->user()->isA('superadmin') ? $abilities 47 | : $this->user()->getAbilities()->pluck('id')->intersect($abilities)->toArray(); 48 | } else { 49 | unset($data['abilities']); 50 | } 51 | } 52 | 53 | // Set roles 54 | if (! empty($data['roles'])) { 55 | if ($data['roles'] && $this->user()->can('assign', app('cortex.auth.role'))) { 56 | $roles = array_map('intval', $this->get('roles', [])); 57 | $data['roles'] = $this->user()->isA('superadmin') ? $roles 58 | : $this->user()->roles->pluck('id')->intersect($roles)->toArray(); 59 | } else { 60 | unset($data['roles']); 61 | } 62 | } 63 | 64 | if ($twoFactor && (isset($data['phone_verified_at']) || $country !== $member->country_code)) { 65 | Arr::set($twoFactor, 'phone.enabled', false); 66 | $data['two_factor'] = $twoFactor; 67 | } 68 | 69 | $this->replace($data); 70 | } 71 | 72 | /** 73 | * Get the validation rules that apply to the request. 74 | * 75 | * @return array 76 | */ 77 | public function rules(): array 78 | { 79 | $member = $this->route('member') ?? app('cortex.auth.member'); 80 | $member->updateRulesUniques(); 81 | $rules = $member->getRules(); 82 | 83 | $rules['password'][] = 'confirmed'; 84 | $rules['roles'] = 'nullable|array'; 85 | $rules['abilities'] = 'nullable|array'; 86 | 87 | return $rules; 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/Http/Requests/Adminarea/PasswordResetPostProcessRequest.php: -------------------------------------------------------------------------------- 1 | 'required|regex:/^([0-9a-f]*)$/', 18 | //'expiration' => 'required|date_format:U', 19 | // Do not validate `token` or `expiration` here since at this stage we can NOT generate viewable 20 | // error, and it is been processed in the controller through EmailVerificationBroker anyway 21 | 'email' => ['required', ...config('validation.rules.email'), 'exists:'.config('cortex.auth.models.admin').',email'], 22 | 'password' => ['required', 'confirmed', config('validation.rules.password')], 23 | ]; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Http/Requests/Adminarea/PasswordResetProcessRequest.php: -------------------------------------------------------------------------------- 1 | only('email', 'expiration', 'token'); 22 | $passwordResetBroker = app('auth.password')->broker($this->passwordResetBroker()); 23 | 24 | $validator->after(function ($validator) use ($passwordResetBroker, $credentials) { 25 | if (! ($user = $passwordResetBroker->getUser($credentials))) { 26 | $validator->errors()->add('email', trans('cortex/auth::'.PasswordResetBrokerContract::INVALID_USER)); 27 | } 28 | 29 | if ($user && ! $passwordResetBroker->validateToken($user, $credentials)) { 30 | $validator->errors()->add('email', trans('cortex/auth::'.PasswordResetBrokerContract::INVALID_TOKEN)); 31 | } 32 | 33 | if (empty($credentials['expiration']) || ! $passwordResetBroker->validateTimestamp($credentials['expiration'])) { 34 | $validator->errors()->add('email', trans('cortex/auth::'.PasswordResetBrokerContract::EXPIRED_TOKEN)); 35 | } 36 | }); 37 | } 38 | 39 | /** 40 | * Get the validation rules that apply to the request. 41 | * 42 | * @return array 43 | */ 44 | public function rules(): array 45 | { 46 | return [ 47 | // Do not validate `token` here since at this stage we can NOT generate viewable error, 48 | // and it is been processed in the controller through PasswordResetBroker anyway 49 | //'token' => 'required|regex:/^([0-9a-f]*)$/', 50 | 'email' => ['required', ...config('validation.rules.email'), 'exists:'.config('cortex.auth.models.admin').',email'], 51 | ]; 52 | } 53 | 54 | /** 55 | * {@inheritdoc} 56 | */ 57 | protected function getRedirectUrl() 58 | { 59 | return $this->redirector->getUrlGenerator()->route('adminarea.cortex.auth.account.passwordreset.request'); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/Http/Requests/Adminarea/PasswordResetRequest.php: -------------------------------------------------------------------------------- 1 | user()) { 22 | throw new GenericException(trans('cortex/auth::messages.passwordreset.already_logged'), route('adminarea.cortex.auth.account.settings').'#security-tab'); 23 | } 24 | 25 | return true; 26 | } 27 | 28 | /** 29 | * Get the validation rules that apply to the request. 30 | * 31 | * @return array 32 | */ 33 | public function rules(): array 34 | { 35 | return []; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Http/Requests/Adminarea/PasswordResetSendRequest.php: -------------------------------------------------------------------------------- 1 | ['required', ...config('validation.rules.email'), 'exists:'.config('cortex.auth.models.admin').',email'], 18 | ]; 19 | } 20 | 21 | /** 22 | * {@inheritdoc} 23 | */ 24 | protected function getRedirectUrl() 25 | { 26 | return $this->redirector->getUrlGenerator()->route('adminarea.cortex.auth.account.passwordreset.request'); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Http/Requests/Adminarea/PhoneVerificationProcessRequest.php: -------------------------------------------------------------------------------- 1 | user() 23 | ?? $this->attemptUser() 24 | ?? app('cortex.auth.admin')->whereNotNull('phone')->where('phone', $this->get('phone'))->first(); 25 | 26 | if (! $user) { 27 | // User instance required to detect active TwoFactor methods 28 | throw new GenericException(trans('cortex/auth::messages.unauthenticated'), route('adminarea.cortex.auth.account.login'), null, 401); 29 | } 30 | 31 | return true; 32 | } 33 | 34 | /** 35 | * Get the validation rules that apply to the request. 36 | * 37 | * @return array 38 | */ 39 | public function rules(): array 40 | { 41 | return [ 42 | 'token' => 'required|digits_between:6,10', 43 | ]; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/Http/Requests/Adminarea/PhoneVerificationRequest.php: -------------------------------------------------------------------------------- 1 | user() 22 | ?? $this->attemptUser() 23 | ?? app('cortex.auth.admin')->whereNotNull('phone')->where('phone', $this->get('phone'))->first(); 24 | 25 | // Redirect users if their phone already verified, no need to process their request 26 | if ($user && $user->hasVerifiedPhone()) { 27 | throw new GenericException(trans('cortex/auth::messages.verification.phone.already_verified'), route('adminarea.cortex.auth.account.settings')); 28 | } 29 | 30 | // Phone field required before verification 31 | if ($user && ! $user->phone) { 32 | throw new GenericException(trans('cortex/auth::messages.account.phone_required'), route('adminarea.cortex.auth.account.settings')); 33 | } 34 | 35 | // Country field required for phone verification 36 | if ($user && ! $user->country_code) { 37 | throw new GenericException(trans('cortex/auth::messages.account.country_required'), route('adminarea.cortex.auth.account.settings')); 38 | } 39 | 40 | // Email verification required for phone verification 41 | if ($user && ! $user->hasVerifiedPhone()) { 42 | throw new GenericException(trans('cortex/auth::messages.account.email_verification_required'), route('adminarea.cortex.auth.account.verification.email.request')); 43 | } 44 | 45 | return true; 46 | } 47 | 48 | /** 49 | * Get the validation rules that apply to the request. 50 | * 51 | * @return array 52 | */ 53 | public function rules(): array 54 | { 55 | return []; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/Http/Requests/Adminarea/PhoneVerificationSendRequest.php: -------------------------------------------------------------------------------- 1 | 'required|phone:AUTO|exists:'.config('cortex.auth.models.admin').',phone', 18 | ]; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Http/Requests/Adminarea/PhoneVerificationVerifyRequest.php: -------------------------------------------------------------------------------- 1 | user() 23 | ?? $this->attemptUser() 24 | ?? app('cortex.auth.admin')->whereNotNull('phone')->where('phone', $this->get('phone'))->first(); 25 | 26 | if (! $user) { 27 | // User instance required to detect active TwoFactor methods 28 | throw new GenericException(trans('cortex/auth::messages.unauthenticated'), route('adminarea.cortex.auth.account.login'), null, 401); 29 | } 30 | 31 | return true; 32 | } 33 | 34 | /** 35 | * Get the validation rules that apply to the request. 36 | * 37 | * @return array 38 | */ 39 | public function rules(): array 40 | { 41 | return []; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/Http/Requests/Adminarea/ReauthenticatePasswordFormRequest.php: -------------------------------------------------------------------------------- 1 | 'required|current_password', 20 | ]; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Http/Requests/Adminarea/RoleFormProcessRequest.php: -------------------------------------------------------------------------------- 1 | all(); 17 | 18 | // Set abilities 19 | if (! empty($data['abilities'])) { 20 | if ($this->user()->can('grant', app('cortex.auth.ability'))) { 21 | $abilities = array_map('intval', $this->get('abilities', [])); 22 | $data['abilities'] = $this->user()->isA('superadmin') ? $abilities 23 | : $this->user()->getAbilities()->pluck('id')->intersect($abilities)->toArray(); 24 | } else { 25 | unset($data['abilities']); 26 | } 27 | } 28 | 29 | $this->replace($data); 30 | } 31 | 32 | /** 33 | * Get the validation rules that apply to the request. 34 | * 35 | * @return array 36 | */ 37 | public function rules(): array 38 | { 39 | $user = $this->route('role') ?? app('cortex.auth.role'); 40 | $user->updateRulesUniques(); 41 | $rules = $user->getRules(); 42 | $rules['abilities'] = 'nullable|array'; 43 | 44 | return $rules; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/Http/Requests/Adminarea/RoleFormRequest.php: -------------------------------------------------------------------------------- 1 | user()->isA('superadmin') && ! $this->user()->roles->contains($this->route('role'))) { 25 | throw new GenericException(trans('cortex/auth::messages.unauthorized'), route('adminarea.cortex.auth.roles.index'), null, 403); 26 | } 27 | 28 | return true; 29 | } 30 | 31 | /** 32 | * Get the validation rules that apply to the request. 33 | * 34 | * @return array 35 | */ 36 | public function rules(): array 37 | { 38 | return []; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/Http/Requests/Frontarea/AccountPasswordRequest.php: -------------------------------------------------------------------------------- 1 | after(function ($validator) { 31 | if (! auth()->getProvider()->validateCredentials($this->user(), ['password' => $this->get('old_password')])) { 32 | $validator->errors()->add('old_password', trans('cortex/auth::messages.account.wrong_password')); 33 | } 34 | 35 | if (auth()->getProvider()->validateCredentials($this->user(), ['password' => $this->get('new_password')])) { 36 | $validator->errors()->add('new_password', trans('cortex/auth::messages.account.different_password')); 37 | } 38 | }); 39 | } 40 | 41 | /** 42 | * Get the validation rules that apply to the request. 43 | * 44 | * @return array 45 | */ 46 | public function rules(): array 47 | { 48 | return [ 49 | 'old_password' => ['required', config('validation.rules.password')], 50 | 'new_password' => ['required', 'confirmed', config('validation.rules.password')], 51 | ]; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/Http/Requests/Frontarea/AccountSettingsRequest.php: -------------------------------------------------------------------------------- 1 | all(); 33 | 34 | $resetTwoFactor = false; 35 | $country = $data['country_code'] ?? null; 36 | $email = $data['email'] ?? null; 37 | $phone = $data['phone'] ?? null; 38 | $user = $this->user(); 39 | $twoFactor = $user->getTwoFactor(); 40 | 41 | if ($email !== $user->email) { 42 | $resetTwoFactor = true; 43 | } 44 | 45 | if ($phone !== $user->phone || $country !== $user->country_code) { 46 | $resetTwoFactor = true; 47 | } 48 | 49 | if ($twoFactor || $resetTwoFactor) { 50 | $data['phone_verified_at'] = null; 51 | Arr::set($twoFactor, 'phone.enabled', false); 52 | $data['two_factor'] = $twoFactor; 53 | } 54 | 55 | $this->replace($data); 56 | } 57 | 58 | /** 59 | * Get the validation rules that apply to the request. 60 | * 61 | * @return array 62 | */ 63 | public function rules(): array 64 | { 65 | $mediaSize = config('cortex.foundation.media.size'); 66 | $mediaMimetypes = config('cortex.foundation.media.mimetypes'); 67 | 68 | $user = $this->user(); 69 | $user->updateRulesUniques(); 70 | $rules = $user->getRules(); 71 | 72 | $rules['profile_picture'] = 'nullable|mimetypes:'.$mediaMimetypes.'|max:'.$mediaSize; 73 | $rules['cover_photo'] = 'nullable|mimetypes:'.$mediaMimetypes.'|max:'.$mediaSize; 74 | 75 | return $rules; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/Http/Requests/Frontarea/AccountTwoFactorPhoneRequest.php: -------------------------------------------------------------------------------- 1 | user(); 33 | 34 | $validator->after(function ($validator) use ($user) { 35 | if (! $user->phone || ! $user->hasVerifiedPhone()) { 36 | $validator->errors()->add('phone', trans('cortex/auth::messages.account.'.(! $user->phone ? 'phone_field_required' : 'phone_verification_required'))); 37 | } 38 | }); 39 | } 40 | 41 | /** 42 | * Get the validation rules that apply to the request. 43 | * 44 | * @return array 45 | */ 46 | public function rules(): array 47 | { 48 | return []; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/Http/Requests/Frontarea/AccountTwoFactorTotpBackupRequest.php: -------------------------------------------------------------------------------- 1 | user()->getTwoFactor(); 22 | 23 | if (! $twoFactor['totp']['enabled']) { 24 | throw new GenericException(trans('cortex/auth::messages.verification.twofactor.totp.cant_backup'), route('frontarea.cortex.auth.account.settings')); 25 | } 26 | 27 | return true; 28 | } 29 | 30 | /** 31 | * Get the validation rules that apply to the request. 32 | * 33 | * @return array 34 | */ 35 | public function rules(): array 36 | { 37 | return []; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Http/Requests/Frontarea/AccountTwoFactorTotpProcessRequest.php: -------------------------------------------------------------------------------- 1 | 'required|digits:6', 32 | ]; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Http/Requests/Frontarea/AuthenticationRequest.php: -------------------------------------------------------------------------------- 1 | 'required|min:3|max:128', 30 | 'password' => ['required', config('validation.rules.password')], 31 | ]; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Http/Requests/Frontarea/EmailVerificationProcessRequest.php: -------------------------------------------------------------------------------- 1 | 'required|regex:/^([0-9a-f]*)$/', 20 | 'email' => ['required', ...config('validation.rules.email'), 'exists:'.config('cortex.auth.models.member').',email'], 21 | ]; 22 | } 23 | 24 | /** 25 | * {@inheritdoc} 26 | */ 27 | protected function getRedirectUrl() 28 | { 29 | return $this->redirector->getUrlGenerator()->route('frontarea.cortex.auth.account.verification.email.request'); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Http/Requests/Frontarea/EmailVerificationRequest.php: -------------------------------------------------------------------------------- 1 | user()) && $user->hasVerifiedEmail()) { 23 | throw new GenericException(trans('cortex/auth::messages.verification.email.already_verified'), route('frontarea.cortex.auth.account.settings')); 24 | } 25 | 26 | return true; 27 | } 28 | 29 | /** 30 | * Get the validation rules that apply to the request. 31 | * 32 | * @return array 33 | */ 34 | public function rules(): array 35 | { 36 | return []; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Http/Requests/Frontarea/EmailVerificationSendRequest.php: -------------------------------------------------------------------------------- 1 | ['required', ...config('validation.rules.email'), 'exists:'.config('cortex.auth.models.member').',email'], 18 | ]; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Http/Requests/Frontarea/MemberRegistrationProcessRequest.php: -------------------------------------------------------------------------------- 1 | all(); 17 | 18 | $data['is_active'] = ! config('cortex.auth.registration.moderated'); 19 | 20 | $this->replace($data); 21 | } 22 | 23 | /** 24 | * Get the validation rules that apply to the request. 25 | * 26 | * @return array 27 | */ 28 | public function rules(): array 29 | { 30 | $rules = app('cortex.auth.member')->getRules(); 31 | 32 | $rules['password'][] = 'confirmed'; 33 | 34 | return $rules; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Http/Requests/Frontarea/MemberRegistrationRequest.php: -------------------------------------------------------------------------------- 1 | replace(array_merge($this->all(), $this->escape($this->except(['password', 'password_confirmation'])))); 42 | } 43 | 44 | /** 45 | * Get the validation rules that apply to the request. 46 | * 47 | * @return array 48 | */ 49 | public function rules(): array 50 | { 51 | return []; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/Http/Requests/Frontarea/PasswordResetPostProcessRequest.php: -------------------------------------------------------------------------------- 1 | 'required|regex:/^([0-9a-f]*)$/', 18 | //'expiration' => 'required|date_format:U', 19 | // Do not validate `token` or `expiration` here since at this stage we can NOT generate viewable 20 | // error, and it is been processed in the controller through EmailVerificationBroker anyway 21 | 'email' => ['required', ...config('validation.rules.email'), 'exists:'.config('cortex.auth.models.member').',email'], 22 | 'password' => ['required', 'confirmed', config('validation.rules.password')], 23 | ]; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Http/Requests/Frontarea/PasswordResetProcessRequest.php: -------------------------------------------------------------------------------- 1 | only('email', 'expiration', 'token'); 22 | $passwordResetBroker = app('auth.password')->broker($this->passwordResetBroker()); 23 | 24 | $validator->after(function ($validator) use ($passwordResetBroker, $credentials) { 25 | if (! ($user = $passwordResetBroker->getUser($credentials))) { 26 | $validator->errors()->add('email', trans('cortex/auth::'.PasswordResetBrokerContract::INVALID_USER)); 27 | } 28 | 29 | if ($user && ! $passwordResetBroker->validateToken($user, $credentials)) { 30 | $validator->errors()->add('email', trans('cortex/auth::'.PasswordResetBrokerContract::INVALID_TOKEN)); 31 | } 32 | 33 | if (empty($credentials['expiration']) || ! $passwordResetBroker->validateTimestamp($credentials['expiration'])) { 34 | $validator->errors()->add('email', trans('cortex/auth::'.PasswordResetBrokerContract::EXPIRED_TOKEN)); 35 | } 36 | }); 37 | } 38 | 39 | /** 40 | * Get the validation rules that apply to the request. 41 | * 42 | * @return array 43 | */ 44 | public function rules(): array 45 | { 46 | return [ 47 | // Do not validate `token` here since at this stage we can NOT generate viewable error, 48 | // and it is been processed in the controller through PasswordResetBroker anyway 49 | //'token' => 'required|regex:/^([0-9a-f]*)$/', 50 | 'email' => ['required', ...config('validation.rules.email'), 'exists:'.config('cortex.auth.models.member').',email'], 51 | ]; 52 | } 53 | 54 | /** 55 | * {@inheritdoc} 56 | */ 57 | protected function getRedirectUrl() 58 | { 59 | return $this->redirector->getUrlGenerator()->route('frontarea.cortex.auth.account.passwordreset.request'); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/Http/Requests/Frontarea/PasswordResetRequest.php: -------------------------------------------------------------------------------- 1 | user()) { 22 | throw new GenericException(trans('cortex/auth::messages.passwordreset.already_logged'), route('frontarea.cortex.auth.account.settings').'#security-tab'); 23 | } 24 | 25 | return true; 26 | } 27 | 28 | /** 29 | * Get the validation rules that apply to the request. 30 | * 31 | * @return array 32 | */ 33 | public function rules(): array 34 | { 35 | return []; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Http/Requests/Frontarea/PasswordResetSendRequest.php: -------------------------------------------------------------------------------- 1 | ['required', ...config('validation.rules.email'), 'exists:'.config('cortex.auth.models.member').',email'], 18 | ]; 19 | } 20 | 21 | /** 22 | * {@inheritdoc} 23 | */ 24 | protected function getRedirectUrl() 25 | { 26 | return $this->redirector->getUrlGenerator()->route('frontarea.cortex.auth.account.passwordreset.request'); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Http/Requests/Frontarea/PhoneVerificationProcessRequest.php: -------------------------------------------------------------------------------- 1 | user() 23 | ?? $this->attemptUser() 24 | ?? app('cortex.auth.member')->whereNotNull('phone')->where('phone', $this->get('phone'))->first(); 25 | 26 | if (! $user) { 27 | // User instance required to detect active TwoFactor methods 28 | throw new GenericException(trans('cortex/auth::messages.unauthenticated'), route('frontarea.cortex.auth.account.login'), null, 401); 29 | } 30 | 31 | return true; 32 | } 33 | 34 | /** 35 | * Get the validation rules that apply to the request. 36 | * 37 | * @return array 38 | */ 39 | public function rules(): array 40 | { 41 | return [ 42 | 'token' => 'required|digits_between:6,10', 43 | ]; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/Http/Requests/Frontarea/PhoneVerificationRequest.php: -------------------------------------------------------------------------------- 1 | user() 22 | ?? $this->attemptUser() 23 | ?? app('cortex.auth.member')->whereNotNull('phone')->where('phone', $this->get('phone'))->first(); 24 | 25 | // Redirect users if their phone already verified, no need to process their request 26 | if ($user && $user->hasVerifiedPhone()) { 27 | throw new GenericException(trans('cortex/auth::messages.verification.phone.already_verified'), route('frontarea.cortex.auth.account.settings')); 28 | } 29 | 30 | // Phone field required before verification 31 | if ($user && ! $user->phone) { 32 | throw new GenericException(trans('cortex/auth::messages.account.phone_required'), route('frontarea.cortex.auth.account.settings')); 33 | } 34 | 35 | // Country field required for phone verification 36 | if ($user && ! $user->country_code) { 37 | throw new GenericException(trans('cortex/auth::messages.account.country_required'), route('frontarea.cortex.auth.account.settings')); 38 | } 39 | 40 | // Email verification required for phone verification 41 | if ($user && ! $user->hasVerifiedPhone()) { 42 | throw new GenericException(trans('cortex/auth::messages.account.email_verification_required'), route('frontarea.cortex.auth.account.verification.email.request')); 43 | } 44 | 45 | return true; 46 | } 47 | 48 | /** 49 | * Get the validation rules that apply to the request. 50 | * 51 | * @return array 52 | */ 53 | public function rules(): array 54 | { 55 | return []; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/Http/Requests/Frontarea/PhoneVerificationSendRequest.php: -------------------------------------------------------------------------------- 1 | 'required|phone:AUTO|exists:'.config('cortex.auth.models.member').',phone', 18 | ]; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Http/Requests/Frontarea/PhoneVerificationVerifyRequest.php: -------------------------------------------------------------------------------- 1 | user() 23 | ?? $this->attemptUser() 24 | ?? app('cortex.auth.member')->whereNotNull('phone')->where('phone', $this->get('phone'))->first(); 25 | 26 | if (! $user) { 27 | // User instance required to detect active TwoFactor methods 28 | throw new GenericException(trans('cortex/auth::messages.unauthenticated'), route('frontarea.cortex.auth.account.login'), null, 401); 29 | } 30 | 31 | return true; 32 | } 33 | 34 | /** 35 | * Get the validation rules that apply to the request. 36 | * 37 | * @return array 38 | */ 39 | public function rules(): array 40 | { 41 | return []; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/Http/Requests/Frontarea/ReauthenticatePasswordFormRequest.php: -------------------------------------------------------------------------------- 1 | 'required|current_password', 20 | ]; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Http/Requests/Frontarea/SocialiteAuthenticationRequest.php: -------------------------------------------------------------------------------- 1 | isEmpty()) { 27 | throw new GenericException(trans('cortex/auth::messages.socialite.disabled')); 28 | } elseif (! $providers->contains($provider = $this->route('provider'))) { 29 | throw new GenericException(trans('cortex/auth::messages.socialite.not_supported', ['provider' => $provider])); 30 | } 31 | 32 | return true; 33 | } 34 | 35 | /** 36 | * Get the validation rules that apply to the request. 37 | * 38 | * @return array 39 | */ 40 | public function rules(): array 41 | { 42 | return []; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/Listeners/EnforceSingleSession.php: -------------------------------------------------------------------------------- 1 | \Cortex\Auth\Http\Middleware\AuthenticateSession 35 | * Also check => logoutOtherDevices method 36 | * @TODO #2: Add support for Laravel Passport login `AccessTokenCreated` 37 | * 38 | * Listen to the authentication login event. 39 | * 40 | * @param \Illuminate\Auth\Events\Login $event 41 | * 42 | * @return void 43 | */ 44 | public function handle(Login $event): void 45 | { 46 | config('cortex.auth.persistence') !== 'single' || $event->user->sessions()->delete(); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/Listeners/LockoutThrottledLogin.php: -------------------------------------------------------------------------------- 1 | request->accessarea()) { 51 | case 'managerarea': 52 | $model = app('cortex.auth.manager'); 53 | break; 54 | case 'adminarea': 55 | $model = app('cortex.auth.admin'); 56 | break; 57 | case 'frontarea': 58 | case 'tenantarea': 59 | default: 60 | $model = app('cortex.auth.member'); 61 | break; 62 | } 63 | 64 | $user = get_login_field($loginfield = $event->request->input('loginfield')) === 'email' 65 | ? $model::where('email', $loginfield)->first() 66 | : $model::where('username', $loginfield)->first(); 67 | 68 | ! $user || $user->notify(new AuthenticationLockoutNotification($event->request->ip(), $event->request->server('HTTP_USER_AGENT'))); 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/Listeners/SendWelcomeEmail.php: -------------------------------------------------------------------------------- 1 | user->notify(new RegistrationSuccessNotification()); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/Notifications/AuthenticationLockoutNotification.php: -------------------------------------------------------------------------------- 1 | ip = $ip; 40 | $this->agent = $agent; 41 | } 42 | 43 | /** 44 | * Get the notification's channels. 45 | * 46 | * @param mixed $notifiable 47 | * 48 | * @return array|string 49 | */ 50 | public function via($notifiable) 51 | { 52 | return ['mail']; 53 | } 54 | 55 | /** 56 | * Build the mail representation of the notification. 57 | * 58 | * @param mixed $notifiable 59 | * 60 | * @return \Illuminate\Notifications\Messages\MailMessage 61 | */ 62 | public function toMail($notifiable): MailMessage 63 | { 64 | return (new MailMessage()) 65 | ->subject(trans('cortex/auth::emails.auth.lockout.subject')) 66 | ->line(trans('cortex/auth::emails.auth.lockout.intro', ['created_at' => Carbon::now(), 'ip' => $this->ip, 'agent' => $this->agent])) 67 | ->line(trans('cortex/auth::emails.auth.lockout.outro')); 68 | } 69 | 70 | /** 71 | * Determine which queues should be used for each notification channel. 72 | * 73 | * @return array 74 | */ 75 | public function viaQueues() 76 | { 77 | return [ 78 | 'mail' => 'listeners', 79 | ]; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/Notifications/PhoneVerificationNotification.php: -------------------------------------------------------------------------------- 1 | method = $method; 40 | $this->force = $force; 41 | } 42 | 43 | /** 44 | * Get the notification's channels. 45 | * 46 | * @param mixed $notifiable 47 | * 48 | * @return array|string 49 | */ 50 | public function via($notifiable) 51 | { 52 | return [AuthyChannel::class]; 53 | } 54 | 55 | /** 56 | * Build the mail representation of the notification. 57 | * 58 | * @return \NotificationChannels\Authy\AuthyMessage 59 | */ 60 | public function toAuthy(): AuthyMessage 61 | { 62 | $message = AuthyMessage::create()->method($this->method); 63 | 64 | if ($this->force) { 65 | $message->force(); 66 | } 67 | 68 | return $message; 69 | } 70 | 71 | /** 72 | * Determine which queues should be used for each notification channel. 73 | * 74 | * @return array 75 | */ 76 | public function viaQueues() 77 | { 78 | return [ 79 | AuthyChannel::class => 'listeners', 80 | ]; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/Notifications/RegistrationSuccessNotification.php: -------------------------------------------------------------------------------- 1 | subject(trans('cortex/auth::emails.register.welcome.subject')) 39 | ->line( 40 | config('cortex.auth.registration.moderated') 41 | ? trans('cortex/auth::emails.register.welcome.intro_moderation') 42 | : trans('cortex/auth::emails.register.welcome.intro_default') 43 | ); 44 | } 45 | 46 | /** 47 | * Determine which queues should be used for each notification channel. 48 | * 49 | * @return array 50 | */ 51 | public function viaQueues() 52 | { 53 | return [ 54 | 'mail' => 'listeners', 55 | ]; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/Scopes/UserScope.php: -------------------------------------------------------------------------------- 1 | request = $request; 28 | } 29 | 30 | public function apply($query) 31 | { 32 | // Filter fields 33 | collect([ 34 | 'country_code' => ['field' => 'country_code', 'operator' => '='], 35 | 'language_code' => ['field' => 'language_code', 'operator' => '='], 36 | 'gender' => ['field' => 'gender', 'operator' => '='], 37 | 'created_at_from' => ['field' => 'created_at', 'operator' => '>='], 38 | 'created_at_to' => ['field' => 'created_at', 'operator' => '<='], 39 | ])->each(function ($filter, $key) use ($query) { 40 | if (! empty($this->request->input($key))) { 41 | $query->where($filter['field'], $filter['operator'], $this->request->input($key)); 42 | } 43 | }); 44 | 45 | // Filter relationships 46 | if (! empty($this->request->input('tags'))) { 47 | $query->whereHas('tags', function (Builder $builder) { 48 | $builder->whereIn('id', $this->request->input('tags')); 49 | }); 50 | } 51 | 52 | if (! empty($this->request->input('role_id'))) { 53 | $query->whereHas('roles', function (Builder $builder) { 54 | $builder->where('id', $this->request->input('role_id')); 55 | }); 56 | } 57 | 58 | return $query; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/Transformers/AbilityTransformer.php: -------------------------------------------------------------------------------- 1 | escape([ 27 | 'id' => (string) $ability->getRouteKey(), 28 | 'title' => (string) $ability->title, 29 | 'name' => (string) $ability->name, 30 | 'created_at' => (string) $ability->created_at, 31 | 'updated_at' => (string) $ability->updated_at, 32 | ]); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Transformers/AdminTransformer.php: -------------------------------------------------------------------------------- 1 | country_code ? country($admin->country_code) : null; 27 | $language = $admin->language_code ? language($admin->language_code) : null; 28 | 29 | return $this->escape([ 30 | 'id' => (string) $admin->getRouteKey(), 31 | 'is_active' => (bool) $admin->is_active, 32 | 'given_name' => (string) $admin->given_name, 33 | 'family_name' => (string) $admin->family_name, 34 | 'username' => (string) $admin->username, 35 | 'email' => (string) $admin->email, 36 | 'email_verified_at' => (string) $admin->email_verified_at, 37 | 'phone' => (string) $admin->phone, 38 | 'phone_verified_at' => (string) $admin->phone_verified_at, 39 | 'country_code' => (string) $country?->getName(), 40 | 'country_emoji' => (string) $country?->getEmoji(), 41 | 'language_code' => (string) $language?->getName(), 42 | 'title' => (string) $admin->title, 43 | 'organization' => (string) $admin->organization, 44 | 'birthday' => (string) $admin->birthday, 45 | 'gender' => (string) $admin->gender, 46 | 'social' => (array) $admin->social, 47 | 'last_activity' => (string) $admin->last_activity, 48 | 'created_at' => (string) $admin->created_at, 49 | 'updated_at' => (string) $admin->updated_at, 50 | ]); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/Transformers/GuardianTransformer.php: -------------------------------------------------------------------------------- 1 | escape([ 27 | 'id' => (string) $guardian->getRouteKey(), 28 | 'is_active' => (bool) $guardian->is_active, 29 | 'username' => (string) $guardian->username, 30 | 'email' => (string) $guardian->email, 31 | 'created_at' => (string) $guardian->created_at, 32 | 'updated_at' => (string) $guardian->updated_at, 33 | ]); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Transformers/MemberTransformer.php: -------------------------------------------------------------------------------- 1 | country_code ? country($member->country_code) : null; 27 | $language = $member->language_code ? language($member->language_code) : null; 28 | 29 | return $this->escape([ 30 | 'id' => (string) $member->getRouteKey(), 31 | 'is_active' => (bool) $member->is_active, 32 | 'given_name' => (string) $member->given_name, 33 | 'family_name' => (string) $member->family_name, 34 | 'username' => (string) $member->username, 35 | 'email' => (string) $member->email, 36 | 'email_verified_at' => (string) $member->email_verified_at, 37 | 'phone' => (string) $member->phone, 38 | 'phone_verified_at' => (string) $member->phone_verified_at, 39 | 'country_code' => (string) $country?->getName(), 40 | 'country_emoji' => (string) $country?->getEmoji(), 41 | 'language_code' => (string) $language?->getName(), 42 | 'title' => (string) $member->title, 43 | 'organization' => (string) $member->organization, 44 | 'birthday' => (string) $member->birthday, 45 | 'gender' => (string) $member->gender, 46 | 'social' => (array) $member->social, 47 | 'last_activity' => (string) $member->last_activity, 48 | 'created_at' => (string) $member->created_at, 49 | 'updated_at' => (string) $member->updated_at, 50 | ]); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/Transformers/RoleTransformer.php: -------------------------------------------------------------------------------- 1 | escape([ 27 | 'id' => (string) $role->getRouteKey(), 28 | 'title' => (string) $role->title, 29 | 'name' => (string) $role->name, 30 | 'created_at' => (string) $role->created_at, 31 | 'updated_at' => (string) $role->updated_at, 32 | ]); 33 | } 34 | } 35 | --------------------------------------------------------------------------------