-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit 'dc5062177900727279051c7be37ede3566416c0a' as 'Modules/U…
…ser'
- Loading branch information
Showing
89 changed files
with
4,876 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.idea/ | ||
/vendor | ||
.php_cs.cache | ||
composer.lock | ||
Modules/ | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
$finder = Symfony\CS\Finder\DefaultFinder::create() | ||
->exclude('Modules') | ||
->exclude('vendor') | ||
->in(__DIR__) | ||
; | ||
|
||
return Symfony\CS\Config\Config::create() | ||
->setUsingCache(true) | ||
->level(Symfony\CS\FixerInterface::PSR2_LEVEL) | ||
->fixers(array( | ||
// Concatenation should be used with at least one whitespace around. | ||
'concat_with_spaces', | ||
// Unused use statements must be removed. | ||
'ordered_use', | ||
// Removes extra empty lines. | ||
'extra_empty_lines', | ||
// Removes line breaks between use statements. | ||
'remove_lines_between_uses', | ||
// An empty line feed should precede a return statement. | ||
'return', | ||
// Unused use statements must be removed. | ||
'unused_use', | ||
// Remove trailing whitespace at the end of blank lines. | ||
'whitespacy_lines', | ||
// There MUST be one blank line after the namespace declaration. | ||
'line_after_namespace', | ||
// There should be exactly one blank line before a namespace declaration. | ||
'single_blank_line_before_namespace', | ||
// Each namespace use MUST go on its own line and there MUST be one blank line after the use statements block. | ||
'single_line_after_imports', | ||
// Ensure there is no code on the same line as the PHP open tag and it is followed by a blankline. | ||
'blankline_after_open_tag', | ||
// Remove duplicated semicolons. | ||
'duplicate_semicolon', | ||
// PHP multi-line arrays should have a trailing comma. | ||
'multiline_array_trailing_comma', | ||
// There should be no empty lines after class opening brace. | ||
'no_blank_lines_after_class_opening', | ||
// There should not be blank lines between docblock and the documented element. | ||
'no_empty_lines_after_phpdocs', | ||
// Phpdocs should start and end with content, excluding the very first and last line of the docblocks. | ||
'phpdoc_trim', | ||
// Removes line breaks between use statements. | ||
'remove_lines_between_uses', | ||
)) | ||
->finder($finder); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
filter: | ||
excluded_paths: [tests/*] | ||
checks: | ||
php: | ||
code_rating: true | ||
remove_extra_empty_lines: true | ||
remove_php_closing_tag: true | ||
remove_trailing_whitespace: true | ||
fix_use_statements: | ||
remove_unused: true | ||
preserve_multiple: false | ||
preserve_blanklines: true | ||
order_alphabetically: true | ||
fix_php_opening_tag: true | ||
fix_linefeed: true | ||
fix_line_ending: true | ||
fix_identation_4spaces: true | ||
fix_doc_comments: true | ||
tools: | ||
external_code_coverage: | ||
timeout: 600 | ||
runs: 3 | ||
php_analyzer: true | ||
php_code_coverage: false | ||
php_code_sniffer: | ||
config: | ||
standard: PSR2 | ||
filter: | ||
paths: ['src'] | ||
php_loc: | ||
enabled: true | ||
excluded_dirs: [vendor, tests] | ||
php_cpd: | ||
enabled: true | ||
excluded_dirs: [vendor, tests] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
rules: | ||
php.interface_has_no_interface_suffix: | ||
enabled: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
language: php | ||
|
||
php: | ||
- 7 | ||
- 5.6 | ||
- hhvm | ||
|
||
env: | ||
- LARAVEL_VERSION="~5.2" TESTBENCH_VERSION="~3.2" | ||
|
||
before_script: | ||
- travis_retry composer install --no-interaction --prefer-source | ||
|
||
script: phpunit | ||
|
||
sudo: false | ||
|
||
notifications: | ||
email: | ||
- [email protected] | ||
- [email protected] | ||
|
||
matrix: | ||
allow_failures: | ||
- php: hhvm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace Modules\User\Composers; | ||
|
||
use Modules\User\Permissions\PermissionManager; | ||
|
||
class PermissionsViewComposer | ||
{ | ||
/** | ||
* @var PermissionManager | ||
*/ | ||
private $permissions; | ||
|
||
public function __construct(PermissionManager $permissions) | ||
{ | ||
$this->permissions = $permissions; | ||
} | ||
|
||
public function compose($view) | ||
{ | ||
// Get all permissions | ||
$view->permissions = $this->permissions->all(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace Modules\User\Composers; | ||
|
||
use Illuminate\Contracts\View\View; | ||
use Modules\User\Contracts\Authentication; | ||
|
||
class UsernameViewComposer | ||
{ | ||
/** | ||
* @var Authentication | ||
*/ | ||
private $auth; | ||
|
||
public function __construct(Authentication $auth) | ||
{ | ||
$this->auth = $auth; | ||
} | ||
|
||
public function compose(View $view) | ||
{ | ||
$view->with('user', $this->auth->user()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
|
||
return [ | ||
/* | ||
|-------------------------------------------------------------------------- | ||
| Define which user driver to use. | ||
|-------------------------------------------------------------------------- | ||
| Current default and only option : Sentinel | ||
*/ | ||
'driver' => 'Sentinel', | ||
/* | ||
|-------------------------------------------------------------------------- | ||
| Define which route to redirect to after a successful login | ||
|-------------------------------------------------------------------------- | ||
*/ | ||
'redirect_route_after_login' => 'homepage', | ||
/* | ||
|-------------------------------------------------------------------------- | ||
| Define which route the user should be redirected to after accessing | ||
| a resource that requires to be logged in | ||
|-------------------------------------------------------------------------- | ||
*/ | ||
'redirect_route_not_logged_in' => 'auth/login', | ||
/* | ||
|-------------------------------------------------------------------------- | ||
| Login column(s) | ||
|-------------------------------------------------------------------------- | ||
| Define which column(s) you'd like to use to login with, currently | ||
| only supported by the Sentinel user driver | ||
*/ | ||
'login-columns' => ['email'], | ||
/* | ||
|-------------------------------------------------------------------------- | ||
| Allow anonymous user registration | ||
|-------------------------------------------------------------------------- | ||
*/ | ||
'allow_user_registration' => true, | ||
/* | ||
|-------------------------------------------------------------------------- | ||
| The default role for new user registrations | ||
| Default: User | ||
|-------------------------------------------------------------------------- | ||
*/ | ||
'default_role' => 'User', | ||
/* | ||
|-------------------------------------------------------------------------- | ||
| Fillable user fields | ||
|-------------------------------------------------------------------------- | ||
| Set the fillable user fields, those fields will be mass assigned | ||
*/ | ||
'fillable' => [ | ||
'email', | ||
'password', | ||
'permissions', | ||
'first_name', | ||
'last_name', | ||
], | ||
/* | ||
|-------------------------------------------------------------------------- | ||
| Dynamic relations | ||
|-------------------------------------------------------------------------- | ||
| Add relations that will be dynamically added to the User entity | ||
*/ | ||
'relations' => [ | ||
// 'extension' => function ($self) { | ||
// return $self->belongsTo(UserExtension::class, 'user_id', 'id')->first(); | ||
// } | ||
], | ||
/* | ||
|-------------------------------------------------------------------------- | ||
| Custom Sidebar Class | ||
|-------------------------------------------------------------------------- | ||
| If you want to customise the admin sidebar ordering or grouping | ||
| You can define your own sidebar class for this module. | ||
| No custom sidebar: null | ||
*/ | ||
'custom-sidebar' => null, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
return [ | ||
'user.users' => [ | ||
'index' => 'user::users.list user', | ||
'create' => 'user::users.create user', | ||
'edit' => 'user::users.edit user', | ||
'destroy' => 'user::users.destroy user', | ||
], | ||
'user.roles' => [ | ||
'index' => 'user::roles.list resource', | ||
'create' => 'user::roles.create resource', | ||
'edit' => 'user::roles.edit resource', | ||
'destroy' => 'user::roles.destroy resource', | ||
], | ||
'account.api-keys' => [ | ||
'index' => 'user::users.list api key', | ||
'create' => 'user::users.create api key', | ||
'destroy' => 'user::users.destroy api key', | ||
], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<?php | ||
|
||
namespace Modules\User\Contracts; | ||
|
||
interface Authentication | ||
{ | ||
/** | ||
* Authenticate a user | ||
* @param array $credentials | ||
* @param bool $remember Remember the user | ||
* @return mixed | ||
*/ | ||
public function login(array $credentials, $remember = false); | ||
|
||
/** | ||
* Register a new user. | ||
* @param array $user | ||
* @return bool | ||
*/ | ||
public function register(array $user); | ||
|
||
/** | ||
* Activate the given used id | ||
* @param int $userId | ||
* @param string $code | ||
* @return mixed | ||
*/ | ||
public function activate($userId, $code); | ||
|
||
/** | ||
* Assign a role to the given user. | ||
* @param \Modules\User\Repositories\UserRepository $user | ||
* @param \Modules\User\Repositories\RoleRepository $role | ||
* @return mixed | ||
*/ | ||
public function assignRole($user, $role); | ||
|
||
/** | ||
* Log the user out of the application. | ||
* @return mixed | ||
*/ | ||
public function logout(); | ||
|
||
/** | ||
* Create an activation code for the given user | ||
* @param $user | ||
* @return mixed | ||
*/ | ||
public function createActivation($user); | ||
|
||
/** | ||
* Create a reminders code for the given user | ||
* @param $user | ||
* @return mixed | ||
*/ | ||
public function createReminderCode($user); | ||
|
||
/** | ||
* Completes the reset password process | ||
* @param $user | ||
* @param string $code | ||
* @param string $password | ||
* @return bool | ||
*/ | ||
public function completeResetPassword($user, $code, $password); | ||
|
||
/** | ||
* Determines if the current user has access to given permission | ||
* @param $permission | ||
* @return bool | ||
*/ | ||
public function hasAccess($permission); | ||
|
||
/** | ||
* Check if the user is logged in | ||
* @return bool | ||
*/ | ||
public function check(); | ||
|
||
/** | ||
* Get the currently logged in user | ||
* @return \Modules\User\Entities\UserInterface | ||
*/ | ||
public function user(); | ||
|
||
/** | ||
* Get the ID for the currently authenticated user | ||
* @return int | ||
*/ | ||
public function id(); | ||
} |
33 changes: 33 additions & 0 deletions
33
Modules/User/Database/Migrations/2016_06_24_193447_create_user_tokens_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
|
||
class CreateUserTokensTable extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::create('user_tokens', function (Blueprint $table) { | ||
$table->increments('id'); | ||
$table->integer('user_id')->unsigned(); | ||
$table->string('access_token'); | ||
$table->timestamps(); | ||
|
||
$table->unique('access_token'); | ||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::drop('user_tokens'); | ||
} | ||
} |
Oops, something went wrong.