Skip to content

Commit d5ab76f

Browse files
committed
Merge commit 'dc5062177900727279051c7be37ede3566416c0a' as 'Modules/User'
1 parent 17f7789 commit d5ab76f

File tree

5,047 files changed

+4759
-926989
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

5,047 files changed

+4759
-926989
lines changed

Diff for: .env.example

-27
This file was deleted.

Diff for: .gitattributes

-4
This file was deleted.

Diff for: .github/ISSUE_TEMPLATE.md

-13
This file was deleted.

Diff for: .gitignore

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1+
.idea/
12
/vendor
2-
/node_modules
3-
/public/storage
4-
Homestead.yaml
5-
Homestead.json
6-
.env
3+
.php_cs.cache
74
composer.lock
5+
Modules/
6+
build

Diff for: Modules/Core/.php_cs renamed to .php_cs

File renamed without changes.

Diff for: .scrutinizer.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
filter:
2+
excluded_paths: [tests/*]
3+
checks:
4+
php:
5+
code_rating: true
6+
remove_extra_empty_lines: true
7+
remove_php_closing_tag: true
8+
remove_trailing_whitespace: true
9+
fix_use_statements:
10+
remove_unused: true
11+
preserve_multiple: false
12+
preserve_blanklines: true
13+
order_alphabetically: true
14+
fix_php_opening_tag: true
15+
fix_linefeed: true
16+
fix_line_ending: true
17+
fix_identation_4spaces: true
18+
fix_doc_comments: true
19+
tools:
20+
external_code_coverage:
21+
timeout: 600
22+
runs: 3
23+
php_analyzer: true
24+
php_code_coverage: false
25+
php_code_sniffer:
26+
config:
27+
standard: PSR2
28+
filter:
29+
paths: ['src']
30+
php_loc:
31+
enabled: true
32+
excluded_dirs: [vendor, tests]
33+
php_cpd:
34+
enabled: true
35+
excluded_dirs: [vendor, tests]
File renamed without changes.

Diff for: .travis.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
language: php
2+
3+
php:
4+
- 7
5+
- 5.6
6+
- hhvm
7+
8+
env:
9+
- LARAVEL_VERSION="~5.2" TESTBENCH_VERSION="~3.2"
10+
11+
before_script:
12+
- travis_retry composer install --no-interaction --prefer-source
13+
14+
script: phpunit
15+
16+
sudo: false
17+
18+
notifications:
19+
email:
20+
21+
22+
23+
matrix:
24+
allow_failures:
25+
- php: hhvm

Diff for: Composers/PermissionsViewComposer.php

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace Modules\User\Composers;
4+
5+
use Modules\User\Permissions\PermissionManager;
6+
7+
class PermissionsViewComposer
8+
{
9+
/**
10+
* @var PermissionManager
11+
*/
12+
private $permissions;
13+
14+
public function __construct(PermissionManager $permissions)
15+
{
16+
$this->permissions = $permissions;
17+
}
18+
19+
public function compose($view)
20+
{
21+
// Get all permissions
22+
$view->permissions = $this->permissions->all();
23+
}
24+
}

Diff for: Composers/UsernameViewComposer.php

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace Modules\User\Composers;
4+
5+
use Illuminate\Contracts\View\View;
6+
use Modules\User\Contracts\Authentication;
7+
8+
class UsernameViewComposer
9+
{
10+
/**
11+
* @var Authentication
12+
*/
13+
private $auth;
14+
15+
public function __construct(Authentication $auth)
16+
{
17+
$this->auth = $auth;
18+
}
19+
20+
public function compose(View $view)
21+
{
22+
$view->with('user', $this->auth->user());
23+
}
24+
}

Diff for: Config/config.php

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?php
2+
3+
return [
4+
/*
5+
|--------------------------------------------------------------------------
6+
| Define which user driver to use.
7+
|--------------------------------------------------------------------------
8+
| Current default and only option : Sentinel
9+
*/
10+
'driver' => 'Sentinel',
11+
/*
12+
|--------------------------------------------------------------------------
13+
| Define which route to redirect to after a successful login
14+
|--------------------------------------------------------------------------
15+
*/
16+
'redirect_route_after_login' => 'homepage',
17+
/*
18+
|--------------------------------------------------------------------------
19+
| Define which route the user should be redirected to after accessing
20+
| a resource that requires to be logged in
21+
|--------------------------------------------------------------------------
22+
*/
23+
'redirect_route_not_logged_in' => 'auth/login',
24+
/*
25+
|--------------------------------------------------------------------------
26+
| Login column(s)
27+
|--------------------------------------------------------------------------
28+
| Define which column(s) you'd like to use to login with, currently
29+
| only supported by the Sentinel user driver
30+
*/
31+
'login-columns' => ['email'],
32+
/*
33+
|--------------------------------------------------------------------------
34+
| Allow anonymous user registration
35+
|--------------------------------------------------------------------------
36+
*/
37+
'allow_user_registration' => true,
38+
/*
39+
|--------------------------------------------------------------------------
40+
| The default role for new user registrations
41+
| Default: User
42+
|--------------------------------------------------------------------------
43+
*/
44+
'default_role' => 'User',
45+
/*
46+
|--------------------------------------------------------------------------
47+
| Fillable user fields
48+
|--------------------------------------------------------------------------
49+
| Set the fillable user fields, those fields will be mass assigned
50+
*/
51+
'fillable' => [
52+
'email',
53+
'password',
54+
'permissions',
55+
'first_name',
56+
'last_name',
57+
],
58+
/*
59+
|--------------------------------------------------------------------------
60+
| Dynamic relations
61+
|--------------------------------------------------------------------------
62+
| Add relations that will be dynamically added to the User entity
63+
*/
64+
'relations' => [
65+
// 'extension' => function ($self) {
66+
// return $self->belongsTo(UserExtension::class, 'user_id', 'id')->first();
67+
// }
68+
],
69+
/*
70+
|--------------------------------------------------------------------------
71+
| Custom Sidebar Class
72+
|--------------------------------------------------------------------------
73+
| If you want to customise the admin sidebar ordering or grouping
74+
| You can define your own sidebar class for this module.
75+
| No custom sidebar: null
76+
*/
77+
'custom-sidebar' => null,
78+
];
File renamed without changes.

Diff for: Contracts/Authentication.php

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<?php
2+
3+
namespace Modules\User\Contracts;
4+
5+
interface Authentication
6+
{
7+
/**
8+
* Authenticate a user
9+
* @param array $credentials
10+
* @param bool $remember Remember the user
11+
* @return mixed
12+
*/
13+
public function login(array $credentials, $remember = false);
14+
15+
/**
16+
* Register a new user.
17+
* @param array $user
18+
* @return bool
19+
*/
20+
public function register(array $user);
21+
22+
/**
23+
* Activate the given used id
24+
* @param int $userId
25+
* @param string $code
26+
* @return mixed
27+
*/
28+
public function activate($userId, $code);
29+
30+
/**
31+
* Assign a role to the given user.
32+
* @param \Modules\User\Repositories\UserRepository $user
33+
* @param \Modules\User\Repositories\RoleRepository $role
34+
* @return mixed
35+
*/
36+
public function assignRole($user, $role);
37+
38+
/**
39+
* Log the user out of the application.
40+
* @return mixed
41+
*/
42+
public function logout();
43+
44+
/**
45+
* Create an activation code for the given user
46+
* @param $user
47+
* @return mixed
48+
*/
49+
public function createActivation($user);
50+
51+
/**
52+
* Create a reminders code for the given user
53+
* @param $user
54+
* @return mixed
55+
*/
56+
public function createReminderCode($user);
57+
58+
/**
59+
* Completes the reset password process
60+
* @param $user
61+
* @param string $code
62+
* @param string $password
63+
* @return bool
64+
*/
65+
public function completeResetPassword($user, $code, $password);
66+
67+
/**
68+
* Determines if the current user has access to given permission
69+
* @param $permission
70+
* @return bool
71+
*/
72+
public function hasAccess($permission);
73+
74+
/**
75+
* Check if the user is logged in
76+
* @return bool
77+
*/
78+
public function check();
79+
80+
/**
81+
* Get the currently logged in user
82+
* @return \Modules\User\Entities\UserInterface
83+
*/
84+
public function user();
85+
86+
/**
87+
* Get the ID for the currently authenticated user
88+
* @return int
89+
*/
90+
public function id();
91+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
6+
class CreateUserTokensTable extends Migration
7+
{
8+
/**
9+
* Run the migrations.
10+
* @return void
11+
*/
12+
public function up()
13+
{
14+
Schema::create('user_tokens', function (Blueprint $table) {
15+
$table->increments('id');
16+
$table->integer('user_id')->unsigned();
17+
$table->string('access_token');
18+
$table->timestamps();
19+
20+
$table->unique('access_token');
21+
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
22+
});
23+
}
24+
25+
/**
26+
* Reverse the migrations.
27+
* @return void
28+
*/
29+
public function down()
30+
{
31+
Schema::drop('user_tokens');
32+
}
33+
}

0 commit comments

Comments
 (0)