├── public
├── favicon.ico
├── robots.txt
├── .htaccess
└── index.php
├── app
├── Listeners
│ └── .gitkeep
├── Events
│ └── Event.php
├── Http
│ ├── Requests
│ │ ├── Request.php
│ │ ├── LoginFormRequest.php
│ │ ├── RegistrationFormRequest.php
│ │ ├── UsersEditFormRequest.php
│ │ └── AdminUsersEditFormRequest.php
│ ├── Controllers
│ │ ├── Controller.php
│ │ ├── Admin
│ │ │ ├── AdminController.php
│ │ │ └── AdminUsersController.php
│ │ ├── StandardUser
│ │ │ ├── StandardUserController.php
│ │ │ └── UsersController.php
│ │ ├── PagesController.php
│ │ ├── RegistrationController.php
│ │ ├── Auth
│ │ │ ├── AuthController.php
│ │ │ └── PasswordController.php
│ │ └── SessionsController.php
│ ├── Middleware
│ │ ├── EncryptCookies.php
│ │ ├── VerifyCsrfToken.php
│ │ ├── SentryAdminUser.php
│ │ ├── SentryStandardUser.php
│ │ ├── SentryNotCurrentUser.php
│ │ ├── SentryAuthenticate.php
│ │ ├── SentryRedirectAdmin.php
│ │ ├── RedirectIfAuthenticated.php
│ │ ├── SentryRedirectIfAuthenticated.php
│ │ └── Authenticate.php
│ ├── Kernel.php
│ └── routes.php
├── Repositories
│ ├── UserRepositoryInterface.php
│ └── DbUserRepository.php
├── helpers.php
├── Providers
│ ├── AppServiceProvider.php
│ ├── BackendServiceProvider.php
│ ├── EventServiceProvider.php
│ └── RouteServiceProvider.php
├── Jobs
│ └── Job.php
├── Console
│ ├── Commands
│ │ └── Inspire.php
│ └── Kernel.php
├── Exceptions
│ └── Handler.php
└── User.php
├── database
├── seeds
│ ├── .gitkeep
│ ├── DatabaseSeeder.php
│ ├── SentryGroupSeeder.php
│ ├── SentryUserGroupSeeder.php
│ └── SentryUserSeeder.php
├── migrations
│ ├── .gitkeep
│ ├── 2014_10_12_100000_create_password_resets_table.php
│ ├── 2012_12_06_225929_migration_cartalyst_sentry_install_groups.php
│ ├── 2012_12_06_225945_migration_cartalyst_sentry_install_users_groups_pivot.php
│ ├── 2012_12_06_225988_migration_cartalyst_sentry_install_throttle.php
│ └── 2012_12_06_225921_migration_cartalyst_sentry_install_users.php
├── .gitignore
└── factories
│ └── ModelFactory.php
├── resources
├── views
│ ├── vendor
│ │ └── .gitkeep
│ ├── emails
│ │ └── password.blade.php
│ ├── pages
│ │ ├── about.blade.php
│ │ ├── contact.blade.php
│ │ └── home.blade.php
│ ├── protected
│ │ ├── admin
│ │ │ ├── admin_dashboard.blade.php
│ │ │ ├── show_user.blade.php
│ │ │ ├── list_users.blade.php
│ │ │ ├── master.blade.php
│ │ │ └── edit_user.blade.php
│ │ └── standardUser
│ │ │ ├── userPage.blade.php
│ │ │ ├── show.blade.php
│ │ │ └── edit.blade.php
│ ├── errors
│ │ └── 503.blade.php
│ ├── welcome.blade.php
│ ├── password
│ │ ├── email.blade.php
│ │ └── reset.blade.php
│ ├── master.blade.php
│ ├── sessions
│ │ └── create.blade.php
│ └── registration
│ │ └── create.blade.php
├── assets
│ └── less
│ │ └── app.less
└── lang
│ └── en
│ ├── pagination.php
│ ├── passwords.php
│ └── validation.php
├── storage
├── app
│ └── .gitignore
├── logs
│ └── .gitignore
└── framework
│ ├── cache
│ └── .gitignore
│ ├── views
│ └── .gitignore
│ ├── sessions
│ └── .gitignore
│ └── .gitignore
├── bootstrap
├── cache
│ └── .gitignore
├── autoload.php
└── app.php
├── .gitignore
├── .gitattributes
├── phpspec.yml
├── package.json
├── .env.example
├── gulpfile.js
├── tests
├── TestCase.php
└── functional
│ ├── PagesTest.php
│ └── AuthTest.php
├── server.php
├── phpunit.xml
├── config
├── services.php
├── compile.php
├── view.php
├── broadcasting.php
├── cache.php
├── auth.php
├── filesystems.php
├── queue.php
├── database.php
├── mail.php
├── session.php
├── packages
│ └── cartalyst
│ │ └── sentry
│ │ └── config.php
└── app.php
├── README.md
├── composer.json
└── artisan
/public/favicon.ico:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/Listeners/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/database/seeds/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/database/migrations/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/database/.gitignore:
--------------------------------------------------------------------------------
1 | *.sqlite
2 |
--------------------------------------------------------------------------------
/resources/views/vendor/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/resources/assets/less/app.less:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/storage/app/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
--------------------------------------------------------------------------------
/bootstrap/cache/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/storage/logs/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/public/robots.txt:
--------------------------------------------------------------------------------
1 | User-agent: *
2 | Disallow:
3 |
--------------------------------------------------------------------------------
/storage/framework/cache/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
--------------------------------------------------------------------------------
/storage/framework/views/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /vendor
2 | /node_modules
3 | .env
4 | .DS_Store
5 |
--------------------------------------------------------------------------------
/storage/framework/sessions/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto
2 | *.css linguist-vendored
3 | *.less linguist-vendored
4 |
--------------------------------------------------------------------------------
/app/Events/Event.php:
--------------------------------------------------------------------------------
1 | {{ url('reset_password/'.$token) }}
2 |
--------------------------------------------------------------------------------
/app/Http/Requests/Request.php:
--------------------------------------------------------------------------------
1 |
2 |
3 | Options -MultiViews
4 |
5 |
6 | RewriteEngine On
7 |
8 | # Redirect Trailing Slashes...
9 | RewriteRule ^(.*)/$ /$1 [L,R=301]
10 |
11 | # Handle Front Controller...
12 | RewriteCond %{REQUEST_FILENAME} !-d
13 | RewriteCond %{REQUEST_FILENAME} !-f
14 | RewriteRule ^ index.php [L]
15 |
16 |
--------------------------------------------------------------------------------
/resources/views/pages/about.blade.php:
--------------------------------------------------------------------------------
1 | @extends('master')
2 |
3 | @section('title', 'About')
4 |
5 | @section('content')
6 |
7 |
8 |
About Page
9 |
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsa, molestiae, nam voluptatibus aspernatur consequuntur fuga totam minus vero aliquam quos eligendi cumque consectetur repellat minima ratione quae animi magni facere.
10 |
11 |
12 | @stop
--------------------------------------------------------------------------------
/resources/views/protected/admin/admin_dashboard.blade.php:
--------------------------------------------------------------------------------
1 | @extends('protected.admin.master')
2 |
3 | @section('title', 'Admin Dashboard')
4 |
5 | @section('content')
6 |
7 | @if (session()->has('flash_message'))
8 | {{ session()->get('flash_message') }}
9 | @endif
10 |
11 |
12 |
13 |
Admin Page
14 |
This page is for admins only!
15 |
16 |
17 |
18 | @endsection
--------------------------------------------------------------------------------
/resources/views/protected/standardUser/userPage.blade.php:
--------------------------------------------------------------------------------
1 | @extends('master')
2 |
3 | @section('title', 'Registered Users')
4 |
5 | @section('content')
6 |
7 | @if (session()->has('flash_message'))
8 | {{ session()->get('flash_message') }}
9 | @endif
10 |
11 | @if (Sentry::check())
12 | {{ "Welcome, " . Sentry::getUser()->first_name }}
13 | @endif
14 |
15 | This is for standard users only!
16 |
17 | @endsection
--------------------------------------------------------------------------------
/resources/views/pages/contact.blade.php:
--------------------------------------------------------------------------------
1 | @extends('master')
2 |
3 | @section('title', 'Contact')
4 |
5 | @section('content')
6 |
7 |
8 |
9 |
Contact Page
10 |
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsa, molestiae, nam voluptatibus aspernatur consequuntur fuga totam minus vero aliquam quos eligendi cumque consectetur repellat minima ratione quae animi magni facere.
11 |
12 |
13 | @endsection
--------------------------------------------------------------------------------
/app/helpers.php:
--------------------------------------------------------------------------------
1 | first($attribute, ':message
');
6 | }
7 |
8 | function set_active($path, $active='active')
9 | {
10 | // return Request::is($path) || Request::is($path . '/*') ? $active: '';
11 | return Request::is($path) || Request::is($path . '/*') ? $active: '';
12 | }
13 |
14 | function set_active_admin($path, $active='active')
15 | {
16 | return Request::is($path) ? $active: '';
17 | }
--------------------------------------------------------------------------------
/app/Http/Controllers/StandardUser/StandardUserController.php:
--------------------------------------------------------------------------------
1 | {{ $user->first_name }}'s Profile
8 |
9 | Email Address: {{ $user->email }}
10 | First Name: {{ $user->first_name }}
11 | Last Name: {{ $user->last_name }}
12 |
13 |
14 | @if(Sentry::check())
15 |
16 | Edit your Profile
17 |
18 | @endif
19 |
20 | @endsection
--------------------------------------------------------------------------------
/app/Providers/AppServiceProvider.php:
--------------------------------------------------------------------------------
1 | call('SentryGroupSeeder');
18 | $this->call('SentryUserSeeder');
19 | $this->call('SentryUserGroupSeeder');
20 |
21 | $this->command->info('All tables seeded!');
22 |
23 | Model::reguard();
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/resources/views/protected/admin/show_user.blade.php:
--------------------------------------------------------------------------------
1 | @extends('protected.admin.master')
2 |
3 | @section('title', 'View Profile')
4 |
5 | @section('content')
6 |
7 | {{ $user->first_name }}'s Profile
8 |
9 | Account Type: {{ $user_group }}
10 | Email Address: {{ $user->email }}
11 | First Name: {{ $user->first_name }}
12 | Last Name: {{ $user->last_name }}
13 |
14 |
15 | @if(Sentry::check())
16 | Edit Profile
17 | @endif
18 |
19 | @endsection
--------------------------------------------------------------------------------
/app/Jobs/Job.php:
--------------------------------------------------------------------------------
1 | '« Previous',
17 | 'next' => 'Next »',
18 |
19 | ];
20 |
--------------------------------------------------------------------------------
/tests/TestCase.php:
--------------------------------------------------------------------------------
1 | make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
22 |
23 | return $app;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/database/seeds/SentryGroupSeeder.php:
--------------------------------------------------------------------------------
1 | delete();
16 |
17 | Sentry::getGroupProvider()->create([
18 | 'name' => 'Users',
19 | ]);
20 |
21 | Sentry::getGroupProvider()->create([
22 | 'name' => 'Admins',
23 | ]);
24 |
25 | $this->command->info('Groups seeded!');
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/server.php:
--------------------------------------------------------------------------------
1 |
8 | */
9 |
10 | $uri = urldecode(
11 | parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
12 | );
13 |
14 | // This file allows us to emulate Apache's "mod_rewrite" functionality from the
15 | // built-in PHP web server. This provides a convenient way to test a Laravel
16 | // application without having installed a "real" web server software here.
17 | if ($uri !== '/' and file_exists(__DIR__.'/public'.$uri)) {
18 | return false;
19 | }
20 |
21 | require_once __DIR__.'/public/index.php';
22 |
--------------------------------------------------------------------------------
/app/Http/Middleware/SentryAdminUser.php:
--------------------------------------------------------------------------------
1 | inGroup($admin)) {
23 | return redirect('login');
24 | }
25 | return $next($request);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/app/Http/Middleware/SentryStandardUser.php:
--------------------------------------------------------------------------------
1 | inGroup($users)) {
23 | return redirect('login');
24 | }
25 | return $next($request);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/resources/views/pages/home.blade.php:
--------------------------------------------------------------------------------
1 | @extends('master')
2 |
3 | @section('title', 'Home')
4 |
5 | @section('content')
6 |
7 |
8 |
Landing Page
9 |
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Mollitia perferendis id odit laudantium non blanditiis debitis repellat nulla accusamus cupiditate unde.
10 |
11 | @if (!Sentry::check())
12 |
13 | Login or Register
14 |
15 | @endif
16 |
17 |
18 | @endsection
--------------------------------------------------------------------------------
/app/Http/Middleware/SentryNotCurrentUser.php:
--------------------------------------------------------------------------------
1 | route()->parameters()['profiles'];
21 |
22 | if ($user->id != $routeID) {
23 | return redirect()->back();
24 | }
25 |
26 | return $next($request);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/app/Http/Requests/LoginFormRequest.php:
--------------------------------------------------------------------------------
1 | 'required|email',
28 | 'password' => 'required',
29 | ];
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/app/Providers/BackendServiceProvider.php:
--------------------------------------------------------------------------------
1 | app->bind(
27 | 'App\Repositories\UserRepositoryInterface',
28 | 'App\Repositories\DbUserRepository'
29 | );
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/app/Repositories/DbUserRepository.php:
--------------------------------------------------------------------------------
1 | where('user_id', $user_id)
25 | ->update(['group_id' => $group_id]);
26 | }
27 |
28 | public function create($fields)
29 | {
30 | return Sentry::createUser($fields);
31 | }
32 |
33 |
34 |
35 | }
--------------------------------------------------------------------------------
/app/Http/Middleware/SentryAuthenticate.php:
--------------------------------------------------------------------------------
1 | ajax()) {
21 | return response('Unauthorized.', 401);
22 | } else {
23 | return redirect()->guest('login');
24 | }
25 | }
26 |
27 | return $next($request);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/database/factories/ModelFactory.php:
--------------------------------------------------------------------------------
1 | define(App\User::class, function ($faker) {
15 | return [
16 | 'name' => $faker->name,
17 | 'email' => $faker->email,
18 | 'password' => str_random(10),
19 | 'remember_token' => str_random(10),
20 | ];
21 | });
22 |
--------------------------------------------------------------------------------
/app/Http/Middleware/SentryRedirectAdmin.php:
--------------------------------------------------------------------------------
1 | inGroup($admin)) {
24 | return redirect()->intended('admin');
25 | }
26 | }
27 | return $next($request);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/app/Console/Commands/Inspire.php:
--------------------------------------------------------------------------------
1 | comment(PHP_EOL.Inspiring::quote().PHP_EOL);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/app/Console/Kernel.php:
--------------------------------------------------------------------------------
1 | command('inspire')
28 | ->hourly();
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/app/Http/Requests/RegistrationFormRequest.php:
--------------------------------------------------------------------------------
1 | 'required|email|unique:users',
28 | 'password' => 'required|confirmed|min:6',
29 | 'first_name' => 'required',
30 | 'last_name' => 'required',
31 | ];
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/database/migrations/2014_10_12_100000_create_password_resets_table.php:
--------------------------------------------------------------------------------
1 | string('email')->index();
17 | $table->string('token')->index();
18 | $table->timestamp('created_at');
19 | });
20 | }
21 |
22 | /**
23 | * Reverse the migrations.
24 | *
25 | * @return void
26 | */
27 | public function down()
28 | {
29 | Schema::drop('password_resets');
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/resources/lang/en/passwords.php:
--------------------------------------------------------------------------------
1 | 'Passwords must be at least six characters and match the confirmation.',
17 | 'user' => "We can't find a user with that e-mail address.",
18 | 'token' => 'This password reset token is invalid.',
19 | 'sent' => 'We have e-mailed your password reset link!',
20 | 'reset' => 'Your password has been reset!',
21 |
22 | ];
23 |
--------------------------------------------------------------------------------
/app/Providers/EventServiceProvider.php:
--------------------------------------------------------------------------------
1 | [
17 | 'App\Listeners\EventListener',
18 | ],
19 | ];
20 |
21 | /**
22 | * Register any other events for your application.
23 | *
24 | * @param \Illuminate\Contracts\Events\Dispatcher $events
25 | * @return void
26 | */
27 | public function boot(DispatcherContract $events)
28 | {
29 | parent::boot($events);
30 |
31 | //
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/database/seeds/SentryUserGroupSeeder.php:
--------------------------------------------------------------------------------
1 | delete();
16 |
17 | $userUser = Sentry::getUserProvider()->findByLogin('user@user.com');
18 | $adminUser = Sentry::getUserProvider()->findByLogin('admin@admin.com');
19 |
20 | $userGroup = Sentry::getGroupProvider()->findByName('Users');
21 | $adminGroup = Sentry::getGroupProvider()->findByName('Admins');
22 |
23 | // Assign the groups to the users
24 | $userUser->addGroup($userGroup);
25 | $adminUser->addGroup($adminGroup);
26 |
27 | $this->command->info('Users assigned to groups seeded!');
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/app/Http/Requests/UsersEditFormRequest.php:
--------------------------------------------------------------------------------
1 | route('profiles'));
19 |
20 | return $user->id == $routeID;
21 | }
22 |
23 | /**
24 | * Get the validation rules that apply to the request.
25 | *
26 | * @return array
27 | */
28 | public function rules()
29 | {
30 | return [
31 | 'email' => 'required|email|unique:users,email,'. $this->route('profiles'),
32 | 'first_name' => 'required',
33 | 'last_name' => 'required',
34 | 'password' => 'confirmed|min:6',
35 | ];
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/app/Http/Middleware/RedirectIfAuthenticated.php:
--------------------------------------------------------------------------------
1 | auth = $auth;
26 | }
27 |
28 | /**
29 | * Handle an incoming request.
30 | *
31 | * @param \Illuminate\Http\Request $request
32 | * @param \Closure $next
33 | * @return mixed
34 | */
35 | public function handle($request, Closure $next)
36 | {
37 | if ($this->auth->check()) {
38 | return redirect('/home');
39 | }
40 |
41 | return $next($request);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/app/Http/Middleware/SentryRedirectIfAuthenticated.php:
--------------------------------------------------------------------------------
1 | auth = $auth;
27 | }
28 |
29 | /**
30 | * Handle an incoming request.
31 | *
32 | * @param \Illuminate\Http\Request $request
33 | * @param \Closure $next
34 | * @return mixed
35 | */
36 | public function handle($request, Closure $next)
37 | {
38 | if (Sentry::check()) {
39 | return redirect('/');
40 | }
41 |
42 | return $next($request);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/database/seeds/SentryUserSeeder.php:
--------------------------------------------------------------------------------
1 | delete();
16 |
17 | Sentry::getUserProvider()->create([
18 | 'email' => 'user@user.com',
19 | 'password' => 'sentryuser',
20 | 'first_name' => 'UserFirstName',
21 | 'last_name' => 'UserLastName',
22 | 'activated' => 1,
23 | ]);
24 |
25 | Sentry::getUserProvider()->create([
26 | 'email' => 'admin@admin.com',
27 | 'password' => 'sentryadmin',
28 | 'first_name' => 'AdminFirstName',
29 | 'last_name' => 'AdminLastName',
30 | 'activated' => 1,
31 | ]);
32 |
33 | $this->command->info('Users seeded!');
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/phpunit.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
14 | ./tests/
15 |
16 |
17 |
18 |
19 | app/
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/config/services.php:
--------------------------------------------------------------------------------
1 | [
18 | 'domain' => '',
19 | 'secret' => '',
20 | ],
21 |
22 | 'mandrill' => [
23 | 'secret' => env('MANDRILL_API_KEY', ''),
24 | ],
25 |
26 | 'ses' => [
27 | 'key' => '',
28 | 'secret' => '',
29 | 'region' => 'us-east-1',
30 | ],
31 |
32 | 'stripe' => [
33 | 'model' => App\User::class,
34 | 'key' => '',
35 | 'secret' => '',
36 | ],
37 |
38 | ];
39 |
--------------------------------------------------------------------------------
/app/Http/Requests/AdminUsersEditFormRequest.php:
--------------------------------------------------------------------------------
1 | route('profiles'));
19 |
20 | // return $user->id == $routeID;
21 |
22 | return true;
23 |
24 | }
25 |
26 | /**
27 | * Get the validation rules that apply to the request.
28 | *
29 | * @return array
30 | */
31 | public function rules()
32 | {
33 | return [
34 | 'account_type' => 'integer|between:1,2',
35 | 'email' => 'required|email|unique:users,email,'. $this->route('profiles'),
36 | 'first_name' => 'required',
37 | 'last_name' => 'required',
38 | 'password' => 'confirmed|min:6',
39 | ];
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/app/Http/Middleware/Authenticate.php:
--------------------------------------------------------------------------------
1 | auth = $auth;
26 | }
27 |
28 | /**
29 | * Handle an incoming request.
30 | *
31 | * @param \Illuminate\Http\Request $request
32 | * @param \Closure $next
33 | * @return mixed
34 | */
35 | public function handle($request, Closure $next)
36 | {
37 | if ($this->auth->guest()) {
38 | if ($request->ajax()) {
39 | return response('Unauthorized.', 401);
40 | } else {
41 | return redirect()->guest('login');
42 | }
43 | }
44 |
45 | return $next($request);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/tests/functional/PagesTest.php:
--------------------------------------------------------------------------------
1 | visit('/')
9 | ->see('Landing Page');
10 | }
11 |
12 | /** @test */
13 | public function it_loads_the_about_page()
14 | {
15 | $this->visit('about')
16 | ->see('About Page');
17 | }
18 |
19 | /** @test */
20 | public function it_loads_the_contact_page()
21 | {
22 | $this->visit('contact')
23 | ->see('Contact Page');
24 | }
25 |
26 | /** @test */
27 | public function it_loads_the_register_page()
28 | {
29 | $this->visit('register')
30 | ->see('Register');
31 | }
32 |
33 | /** @test */
34 | public function it_loads_the_login_page()
35 | {
36 | $this->visit('login')
37 | ->see('Login');
38 | }
39 |
40 | /** @test */
41 | public function it_loads_the_forgot_password_page()
42 | {
43 | $this->visit('forgot_password')
44 | ->see('Password Reset');
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/config/compile.php:
--------------------------------------------------------------------------------
1 | [
17 | //
18 | ],
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Compiled File Providers
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here you may list service providers which define a "compiles" function
26 | | that returns additional files that should be compiled, providing an
27 | | easy way to get common files from any packages you are utilizing.
28 | |
29 | */
30 |
31 | 'providers' => [
32 | //
33 | ],
34 |
35 | ];
36 |
--------------------------------------------------------------------------------
/app/Exceptions/Handler.php:
--------------------------------------------------------------------------------
1 | [
17 | realpath(base_path('resources/views')),
18 | ],
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Compiled View Path
23 | |--------------------------------------------------------------------------
24 | |
25 | | This option determines where all the compiled Blade templates will be
26 | | stored for your application. Typically, this is within the storage
27 | | directory. However, as usual, you are free to change this value.
28 | |
29 | */
30 |
31 | 'compiled' => realpath(storage_path('framework/views')),
32 |
33 | ];
34 |
--------------------------------------------------------------------------------
/resources/views/protected/admin/list_users.blade.php:
--------------------------------------------------------------------------------
1 | @extends('protected.admin.master')
2 |
3 | @section('title', 'List Users')
4 |
5 | @section('content')
6 |
7 | Registered Users
8 | Here you would normally search for users but since this is just a demo, I'm listing all of them.
9 |
10 |
11 |
12 | id
13 | Email
14 | First Name
15 | Last Name
16 |
17 |
18 |
19 |
20 | @foreach ($users as $user)
21 |
22 | {{ $user->id }}
23 | {{ $user->email }}
24 | @if ($user->inGroup($admin))
25 | {{ 'Admin' }}
26 | @endif
27 |
28 | {{ $user->first_name}}
29 | {{ $user->last_name}}
30 |
31 | @endforeach
32 |
33 |
34 |
35 |
36 | @stop
--------------------------------------------------------------------------------
/bootstrap/autoload.php:
--------------------------------------------------------------------------------
1 | group(['namespace' => $this->namespace], function ($router) {
41 | require app_path('Http/routes.php');
42 | });
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Basic Authentication with Sentry
2 |
3 | [See Sentinel version here](https://github.com/drehimself/basic-auth-sentinel).
4 |
5 | Updated to Laravel 5.1. My personal starting point for any Laravel app that requires standard users and admin users. Also has editable profiles (standard users can edit their own profile, admin users can edit all profiles).
6 |
7 | [See demo here](http://authdemo.andremadarang.com/) (demo is Laravel 4 version but it works exactly the same) or install locally with instructions below.
8 |
9 | ## Installation
10 |
11 | This is just local installation using something like MAMP/WAMP or xampp. Of course you are free to use homestead if you like.
12 |
13 | 1. clone the repo and cd into it
14 | 2. `composer install`
15 | 3. make sure db is running and credentials are setup in `config\database.php` (or in your `.env` file).
16 | 4. If you have no `.env` file you can use the example one. Just rename `.env.example` to `.env`. Enter your db credentials here.
17 | 5. `php artisan key:generate`
18 | 6. `php artisan migrate`
19 | 7. `php artisan db:seed`
20 | 8. (Optional) Run `vendor/bin/phpunit` to run some functional tests I have written. Have a look at them in the `tests/functional` folder.
21 | 9. `php artisan serve`
22 | 10. Visit [localhost:8000](http://localhost:8000) in your browser
23 |
--------------------------------------------------------------------------------
/resources/views/errors/503.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Be right back.
5 |
6 |
7 |
8 |
39 |
40 |
41 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/app/User.php:
--------------------------------------------------------------------------------
1 | id == $this->id;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/resources/views/welcome.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Laravel
5 |
6 |
7 |
8 |
43 |
44 |
45 |
46 |
47 |
Laravel 5
48 |
{{ Inspiring::quote() }}
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/app/Http/Controllers/RegistrationController.php:
--------------------------------------------------------------------------------
1 | user = $user;
22 | }
23 |
24 | /**
25 | * Show the form for creating a new resource.
26 | *
27 | * @return Response
28 | */
29 | public function create()
30 | {
31 | return view('registration.create');
32 | }
33 |
34 | /**
35 | * Store a newly created resource in storage.
36 | *
37 | * @return Response
38 | */
39 | public function store(RegistrationFormRequest $request)
40 | {
41 | $input = $request->only('email', 'password', 'first_name', 'last_name');
42 | $input = array_add($input, 'activated', true);
43 |
44 | $user = $this->user->create($input);
45 |
46 | // Find the group using the group name
47 | $usersGroup = \Sentry::findGroupByName('Users');
48 |
49 | // Assign the group to the user
50 | $user->addGroup($usersGroup);
51 |
52 | return redirect('login')->withFlashMessage('User Successfully Created!');
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/database/migrations/2012_12_06_225929_migration_cartalyst_sentry_install_groups.php:
--------------------------------------------------------------------------------
1 | increments('id');
35 | $table->string('name');
36 | $table->text('permissions')->nullable();
37 | $table->timestamps();
38 |
39 | // We'll need to ensure that MySQL uses the InnoDB engine to
40 | // support the indexes, other engines aren't affected.
41 | $table->engine = 'InnoDB';
42 | $table->unique('name');
43 | });
44 | }
45 |
46 | /**
47 | * Reverse the migrations.
48 | *
49 | * @return void
50 | */
51 | public function down()
52 | {
53 | Schema::drop('groups');
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/database/migrations/2012_12_06_225945_migration_cartalyst_sentry_install_users_groups_pivot.php:
--------------------------------------------------------------------------------
1 | integer('user_id')->unsigned();
35 | $table->integer('group_id')->unsigned();
36 |
37 | // We'll need to ensure that MySQL uses the InnoDB engine to
38 | // support the indexes, other engines aren't affected.
39 | $table->engine = 'InnoDB';
40 | $table->primary(array('user_id', 'group_id'));
41 | });
42 | }
43 |
44 | /**
45 | * Reverse the migrations.
46 | *
47 | * @return void
48 | */
49 | public function down()
50 | {
51 | Schema::drop('users_groups');
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/config/broadcasting.php:
--------------------------------------------------------------------------------
1 | env('BROADCAST_DRIVER', 'pusher'),
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Broadcast Connections
21 | |--------------------------------------------------------------------------
22 | |
23 | | Here you may define all of the broadcast connections that will be used
24 | | to broadcast events to other systems or over websockets. Samples of
25 | | each available type of connection are provided inside this array.
26 | |
27 | */
28 |
29 | 'connections' => [
30 |
31 | 'pusher' => [
32 | 'driver' => 'pusher',
33 | 'key' => env('PUSHER_KEY'),
34 | 'secret' => env('PUSHER_SECRET'),
35 | 'app_id' => env('PUSHER_APP_ID'),
36 | ],
37 |
38 | 'redis' => [
39 | 'driver' => 'redis',
40 | 'connection' => 'default',
41 | ],
42 |
43 | 'log' => [
44 | 'driver' => 'log',
45 | ],
46 |
47 | ],
48 |
49 | ];
50 |
--------------------------------------------------------------------------------
/app/Http/Kernel.php:
--------------------------------------------------------------------------------
1 | \App\Http\Middleware\Authenticate::class,
30 | 'auth' => \App\Http\Middleware\SentryAuthenticate::class,
31 | 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
32 | //'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
33 | 'guest' => \App\Http\Middleware\SentryRedirectIfAuthenticated::class,
34 | 'standardUser' => \App\Http\Middleware\SentryStandardUser::class,
35 | 'admin' => \App\Http\Middleware\SentryAdminUser::class,
36 | 'notCurrentUser' => \App\Http\Middleware\SentryNotCurrentUser::class,
37 | 'redirectAdmin' => \App\Http\Middleware\SentryRedirectAdmin::class,
38 | ];
39 | }
40 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "laravel/laravel",
3 | "description": "The Laravel Framework.",
4 | "keywords": ["framework", "laravel"],
5 | "license": "MIT",
6 | "type": "project",
7 | "require": {
8 | "php": ">=5.5.9",
9 | "laravel/framework": "5.1.*",
10 | "cartalyst/sentry": "dev-feature/laravel-5",
11 | "illuminate/html": "5.0.*",
12 | "guzzlehttp/guzzle": "~5.3|~6.0"
13 | },
14 | "require-dev": {
15 | "fzaninotto/faker": "~1.4",
16 | "mockery/mockery": "0.9.*",
17 | "phpunit/phpunit": "~4.0",
18 | "phpspec/phpspec": "~2.1"
19 | },
20 | "autoload": {
21 | "classmap": [
22 | "database"
23 | ],
24 | "psr-4": {
25 | "App\\": "app/"
26 | },
27 | "files": [
28 | "app/helpers.php"
29 | ]
30 | },
31 | "autoload-dev": {
32 | "classmap": [
33 | "tests/TestCase.php"
34 | ]
35 | },
36 | "scripts": {
37 | "post-install-cmd": [
38 | "php artisan clear-compiled",
39 | "php artisan optimize"
40 | ],
41 | "post-update-cmd": [
42 | "php artisan clear-compiled",
43 | "php artisan optimize"
44 | ],
45 | "post-root-package-install": [
46 | "php -r \"copy('.env.example', '.env');\""
47 | ],
48 | "post-create-project-cmd": [
49 | "php artisan key:generate"
50 | ]
51 | },
52 | "config": {
53 | "preferred-install": "dist"
54 | },
55 | "minimum-stability": "dev",
56 | "prefer-stable": true
57 | }
58 |
--------------------------------------------------------------------------------
/database/migrations/2012_12_06_225988_migration_cartalyst_sentry_install_throttle.php:
--------------------------------------------------------------------------------
1 | increments('id');
35 | $table->integer('user_id')->unsigned()->nullable();
36 | $table->string('ip_address')->nullable();
37 | $table->integer('attempts')->default(0);
38 | $table->boolean('suspended')->default(0);
39 | $table->boolean('banned')->default(0);
40 | $table->timestamp('last_attempt_at')->nullable();
41 | $table->timestamp('suspended_at')->nullable();
42 | $table->timestamp('banned_at')->nullable();
43 |
44 | // We'll need to ensure that MySQL uses the InnoDB engine to
45 | // support the indexes, other engines aren't affected.
46 | $table->engine = 'InnoDB';
47 | $table->index('user_id');
48 | });
49 | }
50 |
51 | /**
52 | * Reverse the migrations.
53 | *
54 | * @return void
55 | */
56 | public function down()
57 | {
58 | Schema::drop('throttle');
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/bootstrap/app.php:
--------------------------------------------------------------------------------
1 | singleton(
30 | Illuminate\Contracts\Http\Kernel::class,
31 | App\Http\Kernel::class
32 | );
33 |
34 | $app->singleton(
35 | Illuminate\Contracts\Console\Kernel::class,
36 | App\Console\Kernel::class
37 | );
38 |
39 | $app->singleton(
40 | Illuminate\Contracts\Debug\ExceptionHandler::class,
41 | App\Exceptions\Handler::class
42 | );
43 |
44 | /*
45 | |--------------------------------------------------------------------------
46 | | Return The Application
47 | |--------------------------------------------------------------------------
48 | |
49 | | This script returns the application instance. The instance is given to
50 | | the calling script so we can separate the building of the instances
51 | | from the actual running of the application and sending responses.
52 | |
53 | */
54 |
55 | return $app;
56 |
--------------------------------------------------------------------------------
/artisan:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env php
2 | make(Illuminate\Contracts\Console\Kernel::class);
32 |
33 | $status = $kernel->handle(
34 | $input = new Symfony\Component\Console\Input\ArgvInput,
35 | new Symfony\Component\Console\Output\ConsoleOutput
36 | );
37 |
38 | /*
39 | |--------------------------------------------------------------------------
40 | | Shutdown The Application
41 | |--------------------------------------------------------------------------
42 | |
43 | | Once Artisan has finished running. We will fire off the shutdown events
44 | | so that any final work may be done by the application before we shut
45 | | down the process. This is the last thing to happen to the request.
46 | |
47 | */
48 |
49 | $kernel->terminate($input, $status);
50 |
51 | exit($status);
52 |
--------------------------------------------------------------------------------
/resources/views/protected/standardUser/edit.blade.php:
--------------------------------------------------------------------------------
1 | @extends('master')
2 |
3 | @section('title', 'Edit Profile')
4 |
5 | @section('content')
6 | Edit Profile
7 |
8 | @if (session()->has('flash_message'))
9 | {{ session()->get('flash_message') }}
10 | @endif
11 |
12 | {!! Form::model($user, ['method' => 'PATCH', 'route' => ['profiles.update', $user->id]]) !!}
13 |
14 |
15 |
16 | {!! Form::label('email', 'Email:') !!}
17 | {!! Form::email('email', null, ['class' => 'form-control']) !!}
18 | {!! errors_for('email', $errors) !!}
19 |
20 |
21 |
22 |
23 |
24 | {!! Form::label('first_name', 'First Name:') !!}
25 | {!! Form::text('first_name', null, ['class' => 'form-control']) !!}
26 | {!! errors_for('first_name', $errors) !!}
27 |
28 |
29 |
30 |
31 | {!! Form::label('last_name', 'Last Name:') !!}
32 | {!! Form::text('last_name', null, ['class' => 'form-control']) !!}
33 | {!! errors_for('last_name', $errors) !!}
34 |
35 |
36 |
37 |
38 |
44 |
45 |
46 |
47 | {!! Form::label('password_confirmation', 'Repeat Password:') !!}
48 | {!! Form::password('password_confirmation', ['class' => 'form-control'] ) !!}
49 |
50 |
51 |
52 |
53 |
54 | {!! Form::submit('Update Profile', ['class' => 'btn btn-primary']) !!}
55 |
56 | {!! Form::close() !!}
57 |
58 | @stop
--------------------------------------------------------------------------------
/app/Http/Controllers/Auth/AuthController.php:
--------------------------------------------------------------------------------
1 | middleware('guest', ['except' => 'getLogout']);
33 | }
34 |
35 | /**
36 | * Get a validator for an incoming registration request.
37 | *
38 | * @param array $data
39 | * @return \Illuminate\Contracts\Validation\Validator
40 | */
41 | protected function validator(array $data)
42 | {
43 | return Validator::make($data, [
44 | 'name' => 'required|max:255',
45 | 'email' => 'required|email|max:255|unique:users',
46 | 'password' => 'required|confirmed|min:6',
47 | ]);
48 | }
49 |
50 | /**
51 | * Create a new user instance after a valid registration.
52 | *
53 | * @param array $data
54 | * @return User
55 | */
56 | protected function create(array $data)
57 | {
58 | return User::create([
59 | 'name' => $data['name'],
60 | 'email' => $data['email'],
61 | 'password' => bcrypt($data['password']),
62 | ]);
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/public/index.php:
--------------------------------------------------------------------------------
1 |
8 | */
9 |
10 | /*
11 | |--------------------------------------------------------------------------
12 | | Register The Auto Loader
13 | |--------------------------------------------------------------------------
14 | |
15 | | Composer provides a convenient, automatically generated class loader for
16 | | our application. We just need to utilize it! We'll simply require it
17 | | into the script here so that we don't have to worry about manual
18 | | loading any of our classes later on. It feels nice to relax.
19 | |
20 | */
21 |
22 | require __DIR__.'/../bootstrap/autoload.php';
23 |
24 | /*
25 | |--------------------------------------------------------------------------
26 | | Turn On The Lights
27 | |--------------------------------------------------------------------------
28 | |
29 | | We need to illuminate PHP development, so let us turn on the lights.
30 | | This bootstraps the framework and gets it ready for use, then it
31 | | will load up this application so that we can run it and send
32 | | the responses back to the browser and delight our users.
33 | |
34 | */
35 |
36 | $app = require_once __DIR__.'/../bootstrap/app.php';
37 |
38 | /*
39 | |--------------------------------------------------------------------------
40 | | Run The Application
41 | |--------------------------------------------------------------------------
42 | |
43 | | Once we have the application, we can handle the incoming request
44 | | through the kernel, and send the associated response back to
45 | | the client's browser allowing them to enjoy the creative
46 | | and wonderful application we have prepared for them.
47 | |
48 | */
49 |
50 | $kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
51 |
52 | $response = $kernel->handle(
53 | $request = Illuminate\Http\Request::capture()
54 | );
55 |
56 | $response->send();
57 |
58 | $kernel->terminate($request, $response);
59 |
--------------------------------------------------------------------------------
/app/Http/Controllers/SessionsController.php:
--------------------------------------------------------------------------------
1 | only('email', 'password');
31 |
32 | try {
33 | Sentry::authenticate($input, \Input::has('remember'));
34 | } catch (\Cartalyst\Sentry\Users\UserNotFoundException $e) {
35 | return redirect()->back()->withInput()->withErrorMessage('Invalid credentials provided');
36 | } catch (\Cartalyst\Sentry\Users\UserNotActivatedException $e) {
37 | return redirect()->back()->withInput()->withErrorMessage('User Not Activated.');
38 | }
39 |
40 | // Logged in successfully - redirect based on type of user
41 | $user = Sentry::getUser();
42 | $admin = Sentry::findGroupByName('Admins');
43 | $users = Sentry::findGroupByName('Users');
44 |
45 | if ($user->inGroup($admin)) {
46 | return redirect()->intended('admin');
47 | } elseif ($user->inGroup($users)) {
48 | return redirect()->intended('/');
49 | }
50 | }
51 |
52 | /**
53 | * Remove the specified resource from storage.
54 | *
55 | * @param int $id
56 | * @return Response
57 | */
58 | public function destroy($id=null)
59 | {
60 | Sentry::logout();
61 |
62 | //return Redirect::home();
63 |
64 | return redirect()->route('home');
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/database/migrations/2012_12_06_225921_migration_cartalyst_sentry_install_users.php:
--------------------------------------------------------------------------------
1 | increments('id');
35 | $table->string('email');
36 | $table->string('password');
37 | $table->text('permissions')->nullable();
38 | $table->boolean('activated')->default(0);
39 | $table->string('activation_code')->nullable();
40 | $table->timestamp('activated_at')->nullable();
41 | $table->timestamp('last_login')->nullable();
42 | $table->string('persist_code')->nullable();
43 | $table->string('reset_password_code')->nullable();
44 | $table->string('first_name')->nullable();
45 | $table->string('last_name')->nullable();
46 | $table->timestamps();
47 |
48 | // We'll need to ensure that MySQL uses the InnoDB engine to
49 | // support the indexes, other engines aren't affected.
50 | $table->engine = 'InnoDB';
51 | $table->unique('email');
52 | $table->index('activation_code');
53 | $table->index('reset_password_code');
54 | });
55 | }
56 |
57 | /**
58 | * Reverse the migrations.
59 | *
60 | * @return void
61 | */
62 | public function down()
63 | {
64 | Schema::drop('users');
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/app/Http/routes.php:
--------------------------------------------------------------------------------
1 | ['redirectAdmin']], function()
5 | {
6 | Route::get('/', ['as' => 'home', 'uses' => 'PagesController@getHome']);
7 | Route::get('about', ['as' => 'about', 'uses' => 'PagesController@getAbout']);
8 | Route::get('contact', ['as' => 'contact', 'uses' => 'PagesController@getContact']);
9 | });
10 |
11 | # Registration
12 | Route::group(['middleware' => 'guest'], function()
13 | {
14 | Route::get('register', 'RegistrationController@create');
15 | Route::post('register', ['as' => 'registration.store', 'uses' => 'RegistrationController@store']);
16 | });
17 |
18 | # Authentication
19 | Route::get('login', ['as' => 'login', 'middleware' => 'guest', 'uses' => 'SessionsController@create']);
20 | Route::get('logout', ['as' => 'logout', 'uses' => 'SessionsController@destroy']);
21 | Route::resource('sessions', 'SessionsController' , ['only' => ['create','store','destroy']]);
22 |
23 | # Forgotten Password
24 | Route::group(['middleware' => 'guest'], function()
25 | {
26 | Route::get('forgot_password', 'Auth\PasswordController@getEmail');
27 | Route::post('forgot_password','Auth\PasswordController@postEmail');
28 | Route::get('reset_password/{token}', 'Auth\PasswordController@getReset');
29 | Route::post('reset_password/{token}', 'Auth\PasswordController@postReset');
30 | });
31 |
32 | # Standard User Routes
33 | Route::group(['middleware' => ['auth','standardUser']], function()
34 | {
35 | Route::get('userProtected', 'StandardUser\StandardUserController@getUserProtected');
36 | Route::resource('profiles', 'StandardUser\UsersController', ['only' => ['show', 'edit', 'update']]);
37 | });
38 |
39 | # Admin Routes
40 | Route::group(['middleware' => ['auth', 'admin']], function()
41 | {
42 | Route::get('admin', ['as' => 'admin_dashboard', 'uses' => 'Admin\AdminController@getHome']);
43 | Route::resource('admin/profiles', 'Admin\AdminUsersController', ['only' => ['index', 'show', 'edit', 'update', 'destroy']]);
44 | });
45 |
46 |
--------------------------------------------------------------------------------
/resources/views/password/email.blade.php:
--------------------------------------------------------------------------------
1 | @extends('master')
2 |
3 | @section('title', 'Password Reset Email')
4 |
5 | @section('content')
6 |
7 |
8 |
9 |
10 |
11 |
12 |
Password Reset Link
13 |
14 |
15 | {!! Form::open(['action' => 'Auth\PasswordController@postEmail']) !!}
16 |
17 |
18 | @if (session()->has('flash_message'))
19 |
20 | {{ session()->get('flash_message') }}
21 |
22 | @endif
23 |
24 | @if (count($errors) > 0)
25 |
26 |
27 | @foreach ($errors->all() as $error)
28 | {{ $error }}
29 | @endforeach
30 |
31 |
32 | @endif
33 |
34 | Enter your email and we will send you a link to reset your password.
35 |
36 |
37 |
38 | {!! Form::text('email', null, ['placeholder' => 'Email', 'class' => 'form-control', 'required' => 'required'])!!}
39 |
40 |
41 |
42 |
43 | {!! Form::submit('Send Password Reset Link', ['class' => 'btn btn btn-lg btn-primary btn-block']) !!}
44 |
45 |
46 | {!! Form::close() !!}
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 | @endsection
--------------------------------------------------------------------------------
/config/cache.php:
--------------------------------------------------------------------------------
1 | env('CACHE_DRIVER', 'file'),
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Cache Stores
21 | |--------------------------------------------------------------------------
22 | |
23 | | Here you may define all of the cache "stores" for your application as
24 | | well as their drivers. You may even define multiple stores for the
25 | | same cache driver to group types of items stored in your caches.
26 | |
27 | */
28 |
29 | 'stores' => [
30 |
31 | 'apc' => [
32 | 'driver' => 'apc',
33 | ],
34 |
35 | 'array' => [
36 | 'driver' => 'array',
37 | ],
38 |
39 | 'database' => [
40 | 'driver' => 'database',
41 | 'table' => 'cache',
42 | 'connection' => null,
43 | ],
44 |
45 | 'file' => [
46 | 'driver' => 'file',
47 | 'path' => storage_path('framework/cache'),
48 | ],
49 |
50 | 'memcached' => [
51 | 'driver' => 'memcached',
52 | 'servers' => [
53 | [
54 | 'host' => '127.0.0.1', 'port' => 11211, 'weight' => 100,
55 | ],
56 | ],
57 | ],
58 |
59 | 'redis' => [
60 | 'driver' => 'redis',
61 | 'connection' => 'default',
62 | ],
63 |
64 | ],
65 |
66 | /*
67 | |--------------------------------------------------------------------------
68 | | Cache Key Prefix
69 | |--------------------------------------------------------------------------
70 | |
71 | | When utilizing a RAM based store such as APC or Memcached, there might
72 | | be other applications utilizing the same cache. So, we'll specify a
73 | | value to get prefixed to all our keys so we can avoid collisions.
74 | |
75 | */
76 |
77 | 'prefix' => 'laravel',
78 |
79 | ];
80 |
--------------------------------------------------------------------------------
/resources/views/protected/admin/master.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | @yield('title') - Admin - Basic Auth Sentry
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
38 |
39 |
40 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 | @yield('content')
63 |
64 |
65 |
66 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/config/auth.php:
--------------------------------------------------------------------------------
1 | 'eloquent',
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Authentication Model
23 | |--------------------------------------------------------------------------
24 | |
25 | | When using the "Eloquent" authentication driver, we need to know which
26 | | Eloquent model should be used to retrieve your users. Of course, it
27 | | is often just the "User" model but you may use whatever you like.
28 | |
29 | */
30 |
31 | 'model' => App\User::class,
32 |
33 | /*
34 | |--------------------------------------------------------------------------
35 | | Authentication Table
36 | |--------------------------------------------------------------------------
37 | |
38 | | When using the "Database" authentication driver, we need to know which
39 | | table should be used to retrieve your users. We have chosen a basic
40 | | default value but you may easily change it to any table you like.
41 | |
42 | */
43 |
44 | 'table' => 'users',
45 |
46 | /*
47 | |--------------------------------------------------------------------------
48 | | Password Reset Settings
49 | |--------------------------------------------------------------------------
50 | |
51 | | Here you may set the options for resetting passwords including the view
52 | | that is your password reset e-mail. You can also set the name of the
53 | | table that maintains all of the reset tokens for your application.
54 | |
55 | | The expire time is the number of minutes that the reset token should be
56 | | considered valid. This security feature keeps tokens short-lived so
57 | | they have less time to be guessed. You may change this as needed.
58 | |
59 | */
60 |
61 | 'password' => [
62 | 'email' => 'emails.password',
63 | 'table' => 'password_resets',
64 | 'expire' => 60,
65 | ],
66 |
67 | ];
68 |
--------------------------------------------------------------------------------
/resources/views/protected/admin/edit_user.blade.php:
--------------------------------------------------------------------------------
1 | @extends('protected.admin.master')
2 |
3 | @section('title', 'Edit Profile')
4 |
5 | @section('content')
6 | Edit Profile
7 |
8 | @if (session()->has('flash_message'))
9 | {{ session()->get('flash_message') }}
10 | @endif
11 |
12 | {!! Form::model($user, ['method' => 'PATCH', 'route' => ['admin.profiles.update', $user->id]]) !!}
13 |
14 |
15 | {!! Form::label('account_type', 'Account Type:') !!}
16 | {!! Form::select('account_type', $groups, $user_group, ['class' => 'form-control']) !!}
17 | {!! errors_for('account_type', $errors) !!}
18 |
19 |
20 |
21 |
22 | {!! Form::label('email', 'Email:') !!}
23 | {!! Form::email('email', null, ['class' => 'form-control']) !!}
24 | {!! errors_for('email', $errors) !!}
25 |
26 |
27 |
28 |
29 |
30 | {!! Form::label('first_name', 'First Name:') !!}
31 | {!! Form::text('first_name', null, ['class' => 'form-control']) !!}
32 | {!! errors_for('first_name', $errors) !!}
33 |
34 |
35 |
36 |
37 | {!! Form::label('last_name', 'Last Name:') !!}
38 | {!! Form::text('last_name', null, ['class' => 'form-control']) !!}
39 | {!! errors_for('last_name', $errors) !!}
40 |
41 |
42 |
43 |
44 |
50 |
51 |
52 |
53 | {!! Form::label('password_confirmation', 'Repeat Password:') !!}
54 | {!! Form::password('password_confirmation', ['class' => 'form-control'] )!!}
55 |
56 |
57 |
58 |
59 |
60 | {!! Form::submit('Update Profile', ['class' => 'btn btn-primary']) !!}
61 |
62 | {!! Form::close() !!}
63 |
64 | @endsection
--------------------------------------------------------------------------------
/app/Http/Controllers/StandardUser/UsersController.php:
--------------------------------------------------------------------------------
1 | user = $user;
23 |
24 | $this->middleware('notCurrentUser', ['only' => ['show', 'edit', 'update']]);
25 | }
26 |
27 | /**
28 | * Display the specified resource.
29 | *
30 | * @param int $id
31 | * @return Response
32 | */
33 | public function show($id)
34 | {
35 | // $user = User::findOrFail($id);
36 | $user = $this->user->find($id);
37 |
38 | return view('protected.standardUser.show')->withUser($user);
39 | }
40 |
41 | /**
42 | * Show the form for editing the specified resource.
43 | *
44 | * @param int $id
45 | * @return Response
46 | */
47 | public function edit($id)
48 | {
49 | // $user = User::findOrFail($id);
50 | $user = $this->user->find($id);
51 |
52 | return view('protected.standardUser.edit')->withUser($user);
53 | }
54 |
55 | /**
56 | * Update the specified resource in storage.
57 | *
58 | * @param int $id
59 | * @return Response
60 | */
61 | public function update($id, UsersEditFormRequest $request)
62 | {
63 | // $user = User::findOrFail($id);
64 | $user = $this->user->find($id);
65 |
66 | if (! $request->has("password")) {
67 | $input = $request->only('email', 'first_name', 'last_name');
68 |
69 | //$this->usersEditForm->excludeUserId($user->id)->validate($input);
70 |
71 | $user->fill($input)->save();
72 |
73 | return redirect()->route('profiles.edit', $user->id)
74 | ->withFlashMessage('User has been updated successfully!');
75 |
76 | } else {
77 | $input = $request->only('email', 'first_name', 'last_name', 'password');
78 |
79 | //$this->usersEditForm->excludeUserId($user->id)->validate($input);
80 |
81 | // $input = array_except($input, ['password_confirmation']);
82 |
83 | $user->fill($input)->save();
84 |
85 | $user->save();
86 |
87 | return redirect()->route('profiles.edit', $user->id)
88 | ->withFlashMessage('User (and password) has been updated successfully!');
89 | }
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/config/filesystems.php:
--------------------------------------------------------------------------------
1 | 'local',
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Default Cloud Filesystem Disk
23 | |--------------------------------------------------------------------------
24 | |
25 | | Many applications store files both locally and in the cloud. For this
26 | | reason, you may specify a default "cloud" driver here. This driver
27 | | will be bound as the Cloud disk implementation in the container.
28 | |
29 | */
30 |
31 | 'cloud' => 's3',
32 |
33 | /*
34 | |--------------------------------------------------------------------------
35 | | Filesystem Disks
36 | |--------------------------------------------------------------------------
37 | |
38 | | Here you may configure as many filesystem "disks" as you wish, and you
39 | | may even configure multiple disks of the same driver. Defaults have
40 | | been setup for each driver as an example of the required options.
41 | |
42 | */
43 |
44 | 'disks' => [
45 |
46 | 'local' => [
47 | 'driver' => 'local',
48 | 'root' => storage_path('app'),
49 | ],
50 |
51 | 'ftp' => [
52 | 'driver' => 'ftp',
53 | 'host' => 'ftp.example.com',
54 | 'username' => 'your-username',
55 | 'password' => 'your-password',
56 |
57 | // Optional FTP Settings...
58 | // 'port' => 21,
59 | // 'root' => '',
60 | // 'passive' => true,
61 | // 'ssl' => true,
62 | // 'timeout' => 30,
63 | ],
64 |
65 | 's3' => [
66 | 'driver' => 's3',
67 | 'key' => 'your-key',
68 | 'secret' => 'your-secret',
69 | 'region' => 'your-region',
70 | 'bucket' => 'your-bucket',
71 | ],
72 |
73 | 'rackspace' => [
74 | 'driver' => 'rackspace',
75 | 'username' => 'your-username',
76 | 'key' => 'your-key',
77 | 'container' => 'your-container',
78 | 'endpoint' => 'https://identity.api.rackspacecloud.com/v2.0/',
79 | 'region' => 'IAD',
80 | 'url_type' => 'publicURL',
81 | ],
82 |
83 | ],
84 |
85 | ];
86 |
--------------------------------------------------------------------------------
/config/queue.php:
--------------------------------------------------------------------------------
1 | env('QUEUE_DRIVER', 'sync'),
20 |
21 | /*
22 | |--------------------------------------------------------------------------
23 | | Queue Connections
24 | |--------------------------------------------------------------------------
25 | |
26 | | Here you may configure the connection information for each server that
27 | | is used by your application. A default configuration has been added
28 | | for each back-end shipped with Laravel. You are free to add more.
29 | |
30 | */
31 |
32 | 'connections' => [
33 |
34 | 'sync' => [
35 | 'driver' => 'sync',
36 | ],
37 |
38 | 'database' => [
39 | 'driver' => 'database',
40 | 'table' => 'jobs',
41 | 'queue' => 'default',
42 | 'expire' => 60,
43 | ],
44 |
45 | 'beanstalkd' => [
46 | 'driver' => 'beanstalkd',
47 | 'host' => 'localhost',
48 | 'queue' => 'default',
49 | 'ttr' => 60,
50 | ],
51 |
52 | 'sqs' => [
53 | 'driver' => 'sqs',
54 | 'key' => 'your-public-key',
55 | 'secret' => 'your-secret-key',
56 | 'queue' => 'your-queue-url',
57 | 'region' => 'us-east-1',
58 | ],
59 |
60 | 'iron' => [
61 | 'driver' => 'iron',
62 | 'host' => 'mq-aws-us-east-1.iron.io',
63 | 'token' => 'your-token',
64 | 'project' => 'your-project-id',
65 | 'queue' => 'your-queue-name',
66 | 'encrypt' => true,
67 | ],
68 |
69 | 'redis' => [
70 | 'driver' => 'redis',
71 | 'connection' => 'default',
72 | 'queue' => 'default',
73 | 'expire' => 60,
74 | ],
75 |
76 | ],
77 |
78 | /*
79 | |--------------------------------------------------------------------------
80 | | Failed Queue Jobs
81 | |--------------------------------------------------------------------------
82 | |
83 | | These options configure the behavior of failed queue job logging so you
84 | | can control which database and table are used to store the jobs that
85 | | have failed. You may change them to any database / table you wish.
86 | |
87 | */
88 |
89 | 'failed' => [
90 | 'database' => 'mysql', 'table' => 'failed_jobs',
91 | ],
92 |
93 | ];
94 |
--------------------------------------------------------------------------------
/resources/views/password/reset.blade.php:
--------------------------------------------------------------------------------
1 | @extends('master')
2 |
3 | @section('title', 'Password Reset')
4 |
5 | @section('content')
6 |
7 |
8 |
9 |
10 |
11 |
12 |
Reset Password
13 |
14 |
15 | {!! Form::open(['action' => 'Auth\PasswordController@postReset']) !!}
16 |
17 |
18 | @if (session()->has('flash_message'))
19 |
20 | {{ session()->get('flash_message') }}
21 |
22 | @endif
23 |
24 | @if (session()->has('error_message'))
25 |
26 | {{ session()->get('error_message') }}
27 |
28 | @endif
29 |
30 |
31 |
32 | {!! Form::text('email', null, ['placeholder' => 'Email', 'class' => 'form-control', 'required' => 'required'])!!}
33 | {!! errors_for('email', $errors) !!}
34 |
35 |
36 |
37 |
38 | {!! Form::password('password', ['placeholder' => 'Password','class' => 'form-control', 'required' => 'required'])!!}
39 | {!! errors_for('password', $errors) !!}
40 |
41 |
42 |
43 |
44 | {!! Form::password('password_confirmation', ['placeholder' => 'Password confirmation','class' => 'form-control', 'required' => 'required'])!!}
45 | {!! errors_for('password', $errors) !!}
46 |
47 |
48 |
49 | {!! Form::hidden('token', $token )!!}
50 |
51 |
52 |
53 |
54 | {!! Form::submit('Reset Password', ['class' => 'btn btn btn-lg btn-primary btn-block']) !!}
55 |
56 |
57 | {!! Form::close() !!}
58 |
59 |
60 |
61 |
62 |
63 |
64 | @endsection
--------------------------------------------------------------------------------
/resources/views/master.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | @yield('title') - Basic Auth Sentry
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
40 |
41 |
42 |
60 |
61 |
62 |
63 |
64 |
65 |
66 | @yield('content')
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/resources/views/sessions/create.blade.php:
--------------------------------------------------------------------------------
1 | @extends('master')
2 |
3 | @section('title', 'Login')
4 |
5 | @section('content')
6 |
7 |
8 |
9 |
10 |
11 |
12 |
Login
13 |
14 |
15 | {!! Form::open(['route' => 'sessions.store']) !!}
16 |
17 |
18 | @if (session()->has('flash_message'))
19 |
20 | {{ session()->get('flash_message') }}
21 |
22 | @endif
23 |
24 | @if (session()->has('error_message'))
25 |
26 | {{ session()->get('error_message') }}
27 |
28 | @endif
29 |
30 |
31 |
32 | {!! Form::text('email', null, ['placeholder' => 'Email', 'class' => 'form-control', 'required' => 'required'])!!}
33 | {!! errors_for('email', $errors) !!}
34 |
35 |
36 |
37 |
38 | {!! Form::password('password', ['placeholder' => 'Password','class' => 'form-control', 'required' => 'required'])!!}
39 | {!! errors_for('password', $errors) !!}
40 |
41 |
42 |
43 |
44 |
45 |
46 | {!! Form::checkbox('remember', 'remember') !!} Remember me
47 |
48 |
49 |
50 |
51 |
52 |
53 | {!! Form::submit('Login', ['class' => 'btn btn btn-lg btn-success btn-block']) !!}
54 |
55 |
56 | {!! Form::close() !!}
57 |
58 |
59 |
60 |
Forgot Password?
61 |
62 |
Standard User: user@user.com
63 | Standard User Password: sentryuser
64 |
65 |
Admin User: admin@admin.com
66 | Admin Password: sentryadmin
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | @endsection
--------------------------------------------------------------------------------
/resources/views/registration/create.blade.php:
--------------------------------------------------------------------------------
1 | @extends('master')
2 |
3 | @section('title', 'Register')
4 |
5 | @section('content')
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Register
14 |
15 |
16 | {!! Form::open(['route' => 'registration.store']) !!}
17 |
18 |
19 | @if (session()->has('flash_message'))
20 |
23 | @endif
24 |
25 |
26 |
27 | {!! Form::text('email', null, ['placeholder' => 'Email', 'class' => 'form-control', 'required' => 'required'])!!}
28 | {!! errors_for('email', $errors) !!}
29 |
30 |
31 |
32 |
33 | {!! Form::password('password', ['placeholder' => 'Password', 'class' => 'form-control', 'required' => 'required'])!!}
34 | {!! errors_for('password', $errors) !!}
35 |
36 |
37 |
38 |
39 | {!! Form::password('password_confirmation', ['placeholder' => 'Password Confirm', 'class' => 'form-control', 'required' => 'required'])!!}
40 |
41 |
42 |
43 |
44 |
45 | {!! Form::text('first_name', null, ['placeholder' => 'First Name', 'class' => 'form-control', 'required' => 'required'])!!}
46 | {!! errors_for('first_name', $errors) !!}
47 |
48 |
49 |
50 |
51 | {!! Form::text('last_name', null, ['placeholder' => 'Last Name', 'class' => 'form-control', 'required' => 'required'])!!}
52 | {!! errors_for('last_name', $errors) !!}
53 |
54 |
55 |
56 |
57 | {!! Form::submit('Create Account', ['class' => 'btn btn-lg btn-primary btn-block']) !!}
58 |
59 |
60 |
61 |
62 |
63 |
64 | {!! Form::close() !!}
65 |
66 |
67 |
68 |
Already have an account? Login
69 |
70 |
71 |
72 |
73 |
74 | @endsection
--------------------------------------------------------------------------------
/app/Http/Controllers/Admin/AdminUsersController.php:
--------------------------------------------------------------------------------
1 | user = $user;
23 |
24 |
25 | //$this->middleware('notCurrentUser', ['only' => ['show', 'edit', 'update']]);
26 | }
27 |
28 | /**
29 | * Display a listing of the resource.
30 | *
31 | * @return Response
32 | */
33 | public function index()
34 | {
35 | $users = $this->user->getAll();
36 | $admin = Sentry::findGroupByName('Admins');
37 | return view('protected.admin.list_users')->withUsers($users)->withAdmin($admin);
38 | }
39 |
40 | /**
41 | * Display the specified resource.
42 | *
43 | * @param int $id
44 | * @return Response
45 | */
46 | public function show($id)
47 | {
48 | $user = $this->user->find($id);
49 | $user_group = $user->getGroups()->first()->name;
50 |
51 | $groups = Sentry::findAllGroups();
52 |
53 | return view('protected.admin.show_user')->withUser($user)->withUserGroup($user_group);
54 | }
55 |
56 | /**
57 | * Show the form for editing the specified resource.
58 | *
59 | * @param int $id
60 | * @return Response
61 | */
62 | public function edit($id)
63 | {
64 | $user = $this->user->find($id);
65 |
66 | $groups = Sentry::findAllGroups();
67 |
68 | $user_group = $user->getGroups()->first()->id;
69 |
70 | $array_groups = [];
71 |
72 | foreach ($groups as $group) {
73 | $array_groups = array_add($array_groups, $group->id, $group->name);
74 | }
75 |
76 | return view('protected.admin.edit_user', ['user' => $user, 'groups' => $array_groups, 'user_group' =>$user_group]);
77 | }
78 |
79 | /**
80 | * Update the specified resource in storage.
81 | *
82 | * @param int $id
83 | * @return Response
84 | */
85 | public function update($id, AdminUsersEditFormRequest $request)
86 | {
87 | $user = $this->user->find($id);
88 |
89 | if (! $request->has("password")) {
90 | $input = $request->only('email', 'first_name', 'last_name');
91 |
92 | // $this->adminUsersEditForm->excludeUserId($user->id)->validate($input);
93 |
94 | // $input = array_except($input, ['account_type']);
95 |
96 | $user->fill($input)->save();
97 |
98 | $this->user->updateGroup($id, $request->input('account_type'));
99 |
100 | return redirect()->route('admin.profiles.edit', $user->id)
101 | ->withFlashMessage('User has been updated successfully!');
102 |
103 | } else {
104 | $input = $request->only('email', 'first_name', 'last_name', 'password');
105 |
106 | // $this->adminUsersEditForm->excludeUserId($user->id)->validate($input);
107 |
108 | // $input = array_except($input, ['account_type', 'password_confirmation']);
109 |
110 | $user->fill($input)->save();
111 |
112 | $user->save();
113 |
114 | $this->user->updateGroup($id, $request->input('account_type'));
115 |
116 | return redirect()->route('admin.profiles.edit', $user->id)
117 | ->withFlashMessage('User (and password) has been updated successfully!');
118 | }
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Auth/PasswordController.php:
--------------------------------------------------------------------------------
1 | middleware('guest');
37 | }
38 |
39 |
40 | /**
41 | * Display the form to request a password reset link.
42 | *
43 | * @return \Illuminate\Http\Response
44 | */
45 | public function getEmail()
46 | {
47 | return view('password.email');
48 | }
49 |
50 | /**
51 | * Send a reset link to the given user.
52 | *
53 | * @param \Illuminate\Http\Request $request
54 | * @return \Illuminate\Http\Response
55 | */
56 | public function postEmail(Request $request)
57 | {
58 | $this->validate($request, ['email' => 'required|email']);
59 |
60 | $response = Password::sendResetLink($request->only('email'), function (Message $message) {
61 | $message->subject($this->getEmailSubject());
62 | });
63 |
64 | switch ($response) {
65 | case Password::RESET_LINK_SENT:
66 | return redirect()->back()->with('flash_message', trans($response));
67 |
68 | case Password::INVALID_USER:
69 | return redirect()->back()->withErrors(['email' => trans($response)]);
70 | }
71 | }
72 |
73 |
74 |
75 | /**
76 | * Display the password reset view for the given token.
77 | *
78 | * @param string $token
79 | * @return \Illuminate\Http\Response
80 | */
81 | public function getReset($token = null)
82 | {
83 | if (is_null($token)) {
84 | throw new NotFoundHttpException;
85 | }
86 |
87 | return view('password.reset')->with('token', $token);
88 | }
89 |
90 | /**
91 | * Reset the given user's password.
92 | *
93 | * @param \Illuminate\Http\Request $request
94 | * @return \Illuminate\Http\Response
95 | */
96 | public function postReset(Request $request)
97 | {
98 | $this->validate($request, [
99 | 'token' => 'required',
100 | 'email' => 'required|email',
101 | 'password' => 'required|confirmed',
102 | ]);
103 |
104 | $credentials = $request->only(
105 | 'email', 'password', 'password_confirmation', 'token'
106 | );
107 |
108 | $response = Password::reset($credentials, function ($user, $password) {
109 | $this->resetPassword($user, $password);
110 | });
111 |
112 | switch ($response) {
113 | case Password::PASSWORD_RESET:
114 | return redirect($this->redirectPath())
115 | ->withFlashMessage('Password Reset Successfully!');
116 |
117 | default:
118 | return redirect()->back()
119 | ->withInput($request->only('email'))
120 | ->withErrors(['email' => trans($response)]);
121 | }
122 | }
123 |
124 | /**
125 | * Reset the given user's password.
126 | *
127 | * @param \Illuminate\Contracts\Auth\CanResetPassword $user
128 | * @param string $password
129 | * @return void
130 | */
131 | protected function resetPassword($user, $password)
132 | {
133 | //$user->password = bcrypt($password);
134 | // Sentry hashes password for us
135 | $user->password = $password;
136 |
137 | $user->save();
138 |
139 | //Auth::login($user);
140 | }
141 |
142 |
143 | }
144 |
--------------------------------------------------------------------------------
/config/database.php:
--------------------------------------------------------------------------------
1 | PDO::FETCH_CLASS,
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Default Database Connection Name
21 | |--------------------------------------------------------------------------
22 | |
23 | | Here you may specify which of the database connections below you wish
24 | | to use as your default connection for all database work. Of course
25 | | you may use many connections at once using the Database library.
26 | |
27 | */
28 |
29 | 'default' => env('DB_CONNECTION', 'mysql'),
30 |
31 | /*
32 | |--------------------------------------------------------------------------
33 | | Database Connections
34 | |--------------------------------------------------------------------------
35 | |
36 | | Here are each of the database connections setup for your application.
37 | | Of course, examples of configuring each database platform that is
38 | | supported by Laravel is shown below to make development simple.
39 | |
40 | |
41 | | All database work in Laravel is done through the PHP PDO facilities
42 | | so make sure you have the driver for your particular database of
43 | | choice installed on your machine before you begin development.
44 | |
45 | */
46 |
47 | 'connections' => [
48 |
49 | 'sqlite' => [
50 | 'driver' => 'sqlite',
51 | 'database' => storage_path('database.sqlite'),
52 | 'prefix' => '',
53 | ],
54 |
55 | 'mysql' => [
56 | 'driver' => 'mysql',
57 | 'host' => env('DB_HOST', 'localhost'),
58 | 'database' => env('DB_DATABASE', 'forge'),
59 | 'username' => env('DB_USERNAME', 'forge'),
60 | 'password' => env('DB_PASSWORD', ''),
61 | 'charset' => 'utf8',
62 | 'collation' => 'utf8_unicode_ci',
63 | 'prefix' => '',
64 | 'strict' => false,
65 | ],
66 |
67 | 'pgsql' => [
68 | 'driver' => 'pgsql',
69 | 'host' => env('DB_HOST', 'localhost'),
70 | 'database' => env('DB_DATABASE', 'forge'),
71 | 'username' => env('DB_USERNAME', 'forge'),
72 | 'password' => env('DB_PASSWORD', ''),
73 | 'charset' => 'utf8',
74 | 'prefix' => '',
75 | 'schema' => 'public',
76 | ],
77 |
78 | 'sqlsrv' => [
79 | 'driver' => 'sqlsrv',
80 | 'host' => env('DB_HOST', 'localhost'),
81 | 'database' => env('DB_DATABASE', 'forge'),
82 | 'username' => env('DB_USERNAME', 'forge'),
83 | 'password' => env('DB_PASSWORD', ''),
84 | 'charset' => 'utf8',
85 | 'prefix' => '',
86 | ],
87 |
88 | ],
89 |
90 | /*
91 | |--------------------------------------------------------------------------
92 | | Migration Repository Table
93 | |--------------------------------------------------------------------------
94 | |
95 | | This table keeps track of all the migrations that have already run for
96 | | your application. Using this information, we can determine which of
97 | | the migrations on disk haven't actually been run in the database.
98 | |
99 | */
100 |
101 | 'migrations' => 'migrations',
102 |
103 | /*
104 | |--------------------------------------------------------------------------
105 | | Redis Databases
106 | |--------------------------------------------------------------------------
107 | |
108 | | Redis is an open source, fast, and advanced key-value store that also
109 | | provides a richer set of commands than a typical key-value systems
110 | | such as APC or Memcached. Laravel makes it easy to dig right in.
111 | |
112 | */
113 |
114 | 'redis' => [
115 |
116 | 'cluster' => false,
117 |
118 | 'default' => [
119 | 'host' => '127.0.0.1',
120 | 'port' => 6379,
121 | 'database' => 0,
122 | ],
123 |
124 | ],
125 |
126 | ];
127 |
--------------------------------------------------------------------------------
/config/mail.php:
--------------------------------------------------------------------------------
1 | env('MAIL_DRIVER', 'smtp'),
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | SMTP Host Address
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here you may provide the host address of the SMTP server used by your
26 | | applications. A default option is provided that is compatible with
27 | | the Mailgun mail service which will provide reliable deliveries.
28 | |
29 | */
30 |
31 | 'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
32 |
33 | /*
34 | |--------------------------------------------------------------------------
35 | | SMTP Host Port
36 | |--------------------------------------------------------------------------
37 | |
38 | | This is the SMTP port used by your application to deliver e-mails to
39 | | users of the application. Like the host we have set this value to
40 | | stay compatible with the Mailgun e-mail application by default.
41 | |
42 | */
43 |
44 | 'port' => env('MAIL_PORT', 587),
45 |
46 | /*
47 | |--------------------------------------------------------------------------
48 | | Global "From" Address
49 | |--------------------------------------------------------------------------
50 | |
51 | | You may wish for all e-mails sent by your application to be sent from
52 | | the same address. Here, you may specify a name and address that is
53 | | used globally for all e-mails that are sent by your application.
54 | |
55 | */
56 |
57 | 'from' => ['address' => 'me@andremadarang.com', 'name' => 'Andre Madarang'],
58 |
59 | /*
60 | |--------------------------------------------------------------------------
61 | | E-Mail Encryption Protocol
62 | |--------------------------------------------------------------------------
63 | |
64 | | Here you may specify the encryption protocol that should be used when
65 | | the application send e-mail messages. A sensible default using the
66 | | transport layer security protocol should provide great security.
67 | |
68 | */
69 |
70 | 'encryption' => env('MAIL_ENCRYPTION', 'tls'),
71 |
72 | /*
73 | |--------------------------------------------------------------------------
74 | | SMTP Server Username
75 | |--------------------------------------------------------------------------
76 | |
77 | | If your SMTP server requires a username for authentication, you should
78 | | set it here. This will get used to authenticate with your server on
79 | | connection. You may also set the "password" value below this one.
80 | |
81 | */
82 |
83 | 'username' => env('MAIL_USERNAME'),
84 |
85 | /*
86 | |--------------------------------------------------------------------------
87 | | SMTP Server Password
88 | |--------------------------------------------------------------------------
89 | |
90 | | Here you may set the password required by your SMTP server to send out
91 | | messages from your application. This will be given to the server on
92 | | connection so that the application will be able to send messages.
93 | |
94 | */
95 |
96 | 'password' => env('MAIL_PASSWORD'),
97 |
98 | /*
99 | |--------------------------------------------------------------------------
100 | | Sendmail System Path
101 | |--------------------------------------------------------------------------
102 | |
103 | | When using the "sendmail" driver to send e-mails, we will need to know
104 | | the path to where Sendmail lives on this server. A default path has
105 | | been provided here, which will work well on most of your systems.
106 | |
107 | */
108 |
109 | 'sendmail' => '/usr/sbin/sendmail -bs',
110 |
111 | /*
112 | |--------------------------------------------------------------------------
113 | | Mail "Pretend"
114 | |--------------------------------------------------------------------------
115 | |
116 | | When this option is enabled, e-mail will not actually be sent over the
117 | | web and will instead be written to your application's logs files so
118 | | you may inspect the message. This is great for local development.
119 | |
120 | */
121 |
122 | 'pretend' => false,
123 |
124 | ];
125 |
--------------------------------------------------------------------------------
/resources/lang/en/validation.php:
--------------------------------------------------------------------------------
1 | 'The :attribute must be accepted.',
17 | 'active_url' => 'The :attribute is not a valid URL.',
18 | 'after' => 'The :attribute must be a date after :date.',
19 | 'alpha' => 'The :attribute may only contain letters.',
20 | 'alpha_dash' => 'The :attribute may only contain letters, numbers, and dashes.',
21 | 'alpha_num' => 'The :attribute may only contain letters and numbers.',
22 | 'array' => 'The :attribute must be an array.',
23 | 'before' => 'The :attribute must be a date before :date.',
24 | 'between' => [
25 | 'numeric' => 'The :attribute must be between :min and :max.',
26 | 'file' => 'The :attribute must be between :min and :max kilobytes.',
27 | 'string' => 'The :attribute must be between :min and :max characters.',
28 | 'array' => 'The :attribute must have between :min and :max items.',
29 | ],
30 | 'boolean' => 'The :attribute field must be true or false.',
31 | 'confirmed' => 'The :attribute confirmation does not match.',
32 | 'date' => 'The :attribute is not a valid date.',
33 | 'date_format' => 'The :attribute does not match the format :format.',
34 | 'different' => 'The :attribute and :other must be different.',
35 | 'digits' => 'The :attribute must be :digits digits.',
36 | 'digits_between' => 'The :attribute must be between :min and :max digits.',
37 | 'email' => 'The :attribute must be a valid email address.',
38 | 'filled' => 'The :attribute field is required.',
39 | 'exists' => 'The selected :attribute is invalid.',
40 | 'image' => 'The :attribute must be an image.',
41 | 'in' => 'The selected :attribute is invalid.',
42 | 'integer' => 'The :attribute must be an integer.',
43 | 'ip' => 'The :attribute must be a valid IP address.',
44 | 'max' => [
45 | 'numeric' => 'The :attribute may not be greater than :max.',
46 | 'file' => 'The :attribute may not be greater than :max kilobytes.',
47 | 'string' => 'The :attribute may not be greater than :max characters.',
48 | 'array' => 'The :attribute may not have more than :max items.',
49 | ],
50 | 'mimes' => 'The :attribute must be a file of type: :values.',
51 | 'min' => [
52 | 'numeric' => 'The :attribute must be at least :min.',
53 | 'file' => 'The :attribute must be at least :min kilobytes.',
54 | 'string' => 'The :attribute must be at least :min characters.',
55 | 'array' => 'The :attribute must have at least :min items.',
56 | ],
57 | 'not_in' => 'The selected :attribute is invalid.',
58 | 'numeric' => 'The :attribute must be a number.',
59 | 'regex' => 'The :attribute format is invalid.',
60 | 'required' => 'The :attribute field is required.',
61 | 'required_if' => 'The :attribute field is required when :other is :value.',
62 | 'required_with' => 'The :attribute field is required when :values is present.',
63 | 'required_with_all' => 'The :attribute field is required when :values is present.',
64 | 'required_without' => 'The :attribute field is required when :values is not present.',
65 | 'required_without_all' => 'The :attribute field is required when none of :values are present.',
66 | 'same' => 'The :attribute and :other must match.',
67 | 'size' => [
68 | 'numeric' => 'The :attribute must be :size.',
69 | 'file' => 'The :attribute must be :size kilobytes.',
70 | 'string' => 'The :attribute must be :size characters.',
71 | 'array' => 'The :attribute must contain :size items.',
72 | ],
73 | 'timezone' => 'The :attribute must be a valid zone.',
74 | 'unique' => 'The :attribute has already been taken.',
75 | 'url' => 'The :attribute format is invalid.',
76 |
77 | /*
78 | |--------------------------------------------------------------------------
79 | | Custom Validation Language Lines
80 | |--------------------------------------------------------------------------
81 | |
82 | | Here you may specify custom validation messages for attributes using the
83 | | convention "attribute.rule" to name the lines. This makes it quick to
84 | | specify a specific custom language line for a given attribute rule.
85 | |
86 | */
87 |
88 | 'custom' => [
89 | 'attribute-name' => [
90 | 'rule-name' => 'custom-message',
91 | ],
92 | ],
93 |
94 | /*
95 | |--------------------------------------------------------------------------
96 | | Custom Validation Attributes
97 | |--------------------------------------------------------------------------
98 | |
99 | | The following language lines are used to swap attribute place-holders
100 | | with something more reader friendly such as E-Mail Address instead
101 | | of "email". This simply helps us make messages a little cleaner.
102 | |
103 | */
104 |
105 | 'attributes' => [],
106 |
107 | ];
108 |
--------------------------------------------------------------------------------
/config/session.php:
--------------------------------------------------------------------------------
1 | env('SESSION_DRIVER', 'file'),
20 |
21 | /*
22 | |--------------------------------------------------------------------------
23 | | Session Lifetime
24 | |--------------------------------------------------------------------------
25 | |
26 | | Here you may specify the number of minutes that you wish the session
27 | | to be allowed to remain idle before it expires. If you want them
28 | | to immediately expire on the browser closing, set that option.
29 | |
30 | */
31 |
32 | 'lifetime' => 120,
33 |
34 | 'expire_on_close' => false,
35 |
36 | /*
37 | |--------------------------------------------------------------------------
38 | | Session Encryption
39 | |--------------------------------------------------------------------------
40 | |
41 | | This option allows you to easily specify that all of your session data
42 | | should be encrypted before it is stored. All encryption will be run
43 | | automatically by Laravel and you can use the Session like normal.
44 | |
45 | */
46 |
47 | 'encrypt' => false,
48 |
49 | /*
50 | |--------------------------------------------------------------------------
51 | | Session File Location
52 | |--------------------------------------------------------------------------
53 | |
54 | | When using the native session driver, we need a location where session
55 | | files may be stored. A default has been set for you but a different
56 | | location may be specified. This is only needed for file sessions.
57 | |
58 | */
59 |
60 | 'files' => storage_path('framework/sessions'),
61 |
62 | /*
63 | |--------------------------------------------------------------------------
64 | | Session Database Connection
65 | |--------------------------------------------------------------------------
66 | |
67 | | When using the "database" or "redis" session drivers, you may specify a
68 | | connection that should be used to manage these sessions. This should
69 | | correspond to a connection in your database configuration options.
70 | |
71 | */
72 |
73 | 'connection' => null,
74 |
75 | /*
76 | |--------------------------------------------------------------------------
77 | | Session Database Table
78 | |--------------------------------------------------------------------------
79 | |
80 | | When using the "database" session driver, you may specify the table we
81 | | should use to manage the sessions. Of course, a sensible default is
82 | | provided for you; however, you are free to change this as needed.
83 | |
84 | */
85 |
86 | 'table' => 'sessions',
87 |
88 | /*
89 | |--------------------------------------------------------------------------
90 | | Session Sweeping Lottery
91 | |--------------------------------------------------------------------------
92 | |
93 | | Some session drivers must manually sweep their storage location to get
94 | | rid of old sessions from storage. Here are the chances that it will
95 | | happen on a given request. By default, the odds are 2 out of 100.
96 | |
97 | */
98 |
99 | 'lottery' => [2, 100],
100 |
101 | /*
102 | |--------------------------------------------------------------------------
103 | | Session Cookie Name
104 | |--------------------------------------------------------------------------
105 | |
106 | | Here you may change the name of the cookie used to identify a session
107 | | instance by ID. The name specified here will get used every time a
108 | | new session cookie is created by the framework for every driver.
109 | |
110 | */
111 |
112 | 'cookie' => 'laravel_session',
113 |
114 | /*
115 | |--------------------------------------------------------------------------
116 | | Session Cookie Path
117 | |--------------------------------------------------------------------------
118 | |
119 | | The session cookie path determines the path for which the cookie will
120 | | be regarded as available. Typically, this will be the root path of
121 | | your application but you are free to change this when necessary.
122 | |
123 | */
124 |
125 | 'path' => '/',
126 |
127 | /*
128 | |--------------------------------------------------------------------------
129 | | Session Cookie Domain
130 | |--------------------------------------------------------------------------
131 | |
132 | | Here you may change the domain of the cookie used to identify a session
133 | | in your application. This will determine which domains the cookie is
134 | | available to in your application. A sensible default has been set.
135 | |
136 | */
137 |
138 | 'domain' => null,
139 |
140 | /*
141 | |--------------------------------------------------------------------------
142 | | HTTPS Only Cookies
143 | |--------------------------------------------------------------------------
144 | |
145 | | By setting this option to true, session cookies will only be sent back
146 | | to the server if the browser has a HTTPS connection. This will keep
147 | | the cookie from being sent to you if it can not be done securely.
148 | |
149 | */
150 |
151 | 'secure' => false,
152 |
153 | ];
154 |
--------------------------------------------------------------------------------
/config/packages/cartalyst/sentry/config.php:
--------------------------------------------------------------------------------
1 | 'eloquent',
37 |
38 | /*
39 | |--------------------------------------------------------------------------
40 | | Default Hasher
41 | |--------------------------------------------------------------------------
42 | |
43 | | This option allows you to specify the default hasher used by Sentry
44 | |
45 | | Supported: "native", "bcrypt", "sha256", "whirlpool"
46 | |
47 | */
48 |
49 | 'hasher' => 'native',
50 |
51 | /*
52 | |--------------------------------------------------------------------------
53 | | Cookie
54 | |--------------------------------------------------------------------------
55 | |
56 | | Configuration specific to the cookie component of Sentry.
57 | |
58 | */
59 |
60 | 'cookie' => array(
61 |
62 | /*
63 | |--------------------------------------------------------------------------
64 | | Default Cookie Key
65 | |--------------------------------------------------------------------------
66 | |
67 | | This option allows you to specify the default cookie key used by Sentry.
68 | |
69 | | Supported: string
70 | |
71 | */
72 |
73 | 'key' => 'cartalyst_sentry',
74 |
75 | ),
76 |
77 | /*
78 | |--------------------------------------------------------------------------
79 | | Groups
80 | |--------------------------------------------------------------------------
81 | |
82 | | Configuration specific to the group management component of Sentry.
83 | |
84 | */
85 |
86 | 'groups' => array(
87 |
88 | /*
89 | |--------------------------------------------------------------------------
90 | | Model
91 | |--------------------------------------------------------------------------
92 | |
93 | | When using the "eloquent" driver, we need to know which
94 | | Eloquent models should be used throughout Sentry.
95 | |
96 | */
97 |
98 | 'model' => 'Cartalyst\Sentry\Groups\Eloquent\Group',
99 |
100 | ),
101 |
102 | /*
103 | |--------------------------------------------------------------------------
104 | | Users
105 | |--------------------------------------------------------------------------
106 | |
107 | | Configuration specific to the user management component of Sentry.
108 | |
109 | */
110 |
111 | 'users' => array(
112 |
113 | /*
114 | |--------------------------------------------------------------------------
115 | | Model
116 | |--------------------------------------------------------------------------
117 | |
118 | | When using the "eloquent" driver, we need to know which
119 | | Eloquent models should be used throughout Sentry.
120 | |
121 | */
122 |
123 | 'model' => 'User',
124 | //'model' => 'Cartalyst\Sentry\Users\Eloquent\User',
125 |
126 | /*
127 | |--------------------------------------------------------------------------
128 | | Login Attribute
129 | |--------------------------------------------------------------------------
130 | |
131 | | If you're using the "eloquent" driver and extending the base Eloquent
132 | | model, we allow you to globally override the login attribute without
133 | | even subclassing the model, simply by specifying the attribute below.
134 | |
135 | */
136 |
137 | 'login_attribute' => 'email',
138 |
139 | ),
140 |
141 | /*
142 | |--------------------------------------------------------------------------
143 | | User Groups Pivot Table
144 | |--------------------------------------------------------------------------
145 | |
146 | | When using the "eloquent" driver, you can specify the table name
147 | | for the user groups pivot table.
148 | |
149 | | Default: users_groups
150 | |
151 | */
152 |
153 | 'user_groups_pivot_table' => 'users_groups',
154 |
155 | /*
156 | |--------------------------------------------------------------------------
157 | | Throttling
158 | |--------------------------------------------------------------------------
159 | |
160 | | Throttling is an optional security feature for authentication, which
161 | | enables limiting of login attempts and the suspension & banning of users.
162 | |
163 | */
164 |
165 | 'throttling' => array(
166 |
167 | /*
168 | |--------------------------------------------------------------------------
169 | | Throttling
170 | |--------------------------------------------------------------------------
171 | |
172 | | Enable throttling or not. Throttling is where users are only allowed a
173 | | certain number of login attempts before they are suspended. Suspension
174 | | must be removed before a new login attempt is allowed.
175 | |
176 | */
177 |
178 | 'enabled' => true,
179 |
180 | /*
181 | |--------------------------------------------------------------------------
182 | | Model
183 | |--------------------------------------------------------------------------
184 | |
185 | | When using the "eloquent" driver, we need to know which
186 | | Eloquent models should be used throughout Sentry.
187 | |
188 | */
189 |
190 | 'model' => 'Cartalyst\Sentry\Throttling\Eloquent\Throttle',
191 |
192 | /*
193 | |--------------------------------------------------------------------------
194 | | Attempts Limit
195 | |--------------------------------------------------------------------------
196 | |
197 | | When using the "eloquent" driver and extending the base Eloquent model,
198 | | you have the option to globally set the login attempts.
199 | |
200 | | Supported: int
201 | |
202 | */
203 |
204 | 'attempt_limit' => 5,
205 |
206 | /*
207 | |--------------------------------------------------------------------------
208 | | Suspension Time
209 | |--------------------------------------------------------------------------
210 | |
211 | | When using the "eloquent" driver and extending the base Eloquent model,
212 | | you have the option to globally set the suspension time, in minutes.
213 | |
214 | | Supported: int
215 | |
216 | */
217 |
218 | 'suspension_time' => 15,
219 |
220 | ),
221 |
222 | );
223 |
--------------------------------------------------------------------------------
/tests/functional/AuthTest.php:
--------------------------------------------------------------------------------
1 | visit('register')
17 | ->type('blah@blah.com', 'email')
18 | ->type('password', 'password')
19 | ->type('password', 'password_confirmation')
20 | ->type('Andre', 'first_name')
21 | ->type('Madarang', 'last_name')
22 | ->press('Create Account')
23 | ->seeInDatabase('users', ['email' => 'blah@blah.com'])
24 | ->seePageIs('login');
25 | }
26 |
27 | /** @test */
28 | public function it_does_not_register_an_exisiting_user()
29 | {
30 | $this->visit('register')
31 | ->type('user@user.com', 'email')
32 | ->type('password', 'password')
33 | ->type('password', 'password_confirmation')
34 | ->type('Andre', 'first_name')
35 | ->type('Madarang', 'last_name')
36 | ->press('Create Account')
37 | ->seePageIs('register')
38 | ->see('email has already been taken');
39 | }
40 |
41 | // removed because mailer might not be setup on most people's local machine
42 | // /** @test */
43 | // public function it_finds_an_email_for_forgot_password()
44 | // {
45 | // $this->visit('forgot_password')
46 | // ->type('user@user.com', 'email')
47 | // ->press('Send Password Reset Link')
48 | // ->seePageIs('forgot_password')
49 | // ->see('We have e-mailed your password reset link');
50 | // }
51 |
52 | /** @test */
53 | // public function it_does_not_find_an_email_for_forgot_password()
54 | // {
55 | // $this->visit('forgot_password')
56 | // ->type('nouser@nouser.com', 'email')
57 | // ->press('Send Password Reset Link')
58 | // ->seePageIs('forgot_password')
59 | // //escaping the ' doesn't seem to work
60 | // ->see('can't find a user with that e-mail address.');
61 | // }
62 |
63 |
64 |
65 | /** @test */
66 | public function it_denies_an_incorrect_login()
67 | {
68 | $this->visit('login')
69 | ->type('nouser@nouser.com', 'email')
70 | ->type('password', 'password')
71 | ->press('Login')
72 | ->seePageIs('login')
73 | ->see('Invalid Credentials Provided');
74 |
75 | }
76 |
77 | /** @test */
78 | public function it_logs_in_a_standard_user()
79 | {
80 | $this->login_standard_user()
81 | ->click('Registered Users Only')
82 | ->see('This is for standard users only');
83 | }
84 |
85 | /** @test */
86 | public function it_allows_a_standard_user_to_edit_own_information()
87 | {
88 |
89 | $this->login_standard_user()
90 | ->click('My Profile')
91 | ->click('Edit your Profile')
92 | ->type('firstChanged', 'first_name')
93 | ->type('lastChanged', 'last_name')
94 | ->press('Update Profile')
95 | ->seeInDatabase('users', ['first_name' => 'firstChanged', 'last_name' => 'lastChanged'])
96 | ->see('User has been updated successfully');
97 | }
98 |
99 | /** @test */
100 | public function it_allows_a_standard_user_to_edit_own_information_and_password()
101 | {
102 | $this->login_standard_user()
103 | ->click('My Profile')
104 | ->click('Edit your Profile')
105 | ->type('firstChanged', 'first_name')
106 | ->type('lastChanged', 'last_name')
107 | ->type('passwordnew', 'password')
108 | ->type('passwordnew', 'password_confirmation')
109 | ->press('Update Profile')
110 | ->seeInDatabase('users', ['first_name' => 'firstChanged', 'last_name' => 'lastChanged'])
111 | ->see('User (and password) has been updated successfully');
112 | }
113 |
114 | /** @test */
115 | public function it_denies_a_standard_user_access_to_another_account()
116 | {
117 | $this->login_standard_user()
118 | ->click('My Profile')
119 | ->visit('profiles/2')
120 | ->seePageIs('profiles/' . Sentry::getUser()->id)
121 | ->visit('profiles/2/edit')
122 | ->seePageIs('profiles/' . Sentry::getUser()->id);
123 | }
124 |
125 | /** @test */
126 | public function it_denies_a_standard_user_access_to_admin_account()
127 | {
128 | $this->login_standard_user()
129 | ->visit('admin')
130 | ->seePageIs('/');
131 | }
132 |
133 | /** @test */
134 | public function it_denies_a_standard_user_access_to_login_page()
135 | {
136 | $this->login_standard_user()
137 | ->visit('login')
138 | ->seePageIs('/');
139 | }
140 |
141 | /** @test */
142 | public function it_denies_a_standard_user_access_to_register_page()
143 | {
144 | $this->login_standard_user()
145 | ->visit('register')
146 | ->seePageIs('/');
147 | }
148 |
149 | /** @test */
150 | public function it_denies_a_standard_user_access_to_forgot_password_page()
151 | {
152 | $this->login_standard_user()
153 | ->visit('forgot_password')
154 | ->seePageIs('/');
155 | }
156 |
157 | /** @test */
158 | public function it_logs_in_an_admin_user()
159 | {
160 | $this->login_admin_user()
161 | ->seePageIs('admin');
162 | }
163 |
164 | /** @test */
165 | public function it_allows_an_admin_user_to_edit_own_information()
166 | {
167 | $this->login_admin_user()
168 | ->click('List Users')
169 | ->click('admin@admin.com')
170 | ->click('Edit Profile')
171 | ->type('firstChanged', 'first_name')
172 | ->type('lastChanged', 'last_name')
173 | ->press('Update Profile')
174 | ->seeInDatabase('users', ['first_name' => 'firstChanged', 'last_name' => 'lastChanged'])
175 | ->see('User has been updated successfully');
176 |
177 | }
178 |
179 | /** @test */
180 | public function it_allows_an_admin_user_to_edit_another_users_information()
181 | {
182 | $this->login_admin_user()
183 | ->click('List Users')
184 | ->click('user@user.com')
185 | ->click('Edit Profile')
186 | ->select('2', 'account_type')
187 | ->type('firstChanged', 'first_name')
188 | ->type('lastChanged', 'last_name')
189 | ->press('Update Profile')
190 | ->seeInDatabase('users', ['first_name' => 'firstChanged', 'last_name' => 'lastChanged'])
191 | ->seeInDatabase('users_groups', ['user_id' => 1, 'group_id' => 2])
192 | ->see('User has been updated successfully');
193 | }
194 |
195 | /** @test */
196 | public function it_denies_an_admin_user_access_to_home_page()
197 | {
198 | $this->login_admin_user()
199 | ->visit('/')
200 | ->seePageIs('admin');
201 | }
202 |
203 | /** @test */
204 | public function it_denies_an_admin_user_access_to_about_page()
205 | {
206 | $this->login_admin_user()
207 | ->visit('about')
208 | ->seePageIs('admin');
209 | }
210 |
211 | /** @test */
212 | public function it_denies_an_admin_user_access_to_contact_page()
213 | {
214 | $this->login_admin_user()
215 | ->visit('contact')
216 | ->seePageIs('admin');
217 | }
218 |
219 |
220 | protected function login_standard_user()
221 | {
222 | return $this->visit('login')
223 | ->type('user@user.com', 'email')
224 | ->type('sentryuser', 'password')
225 | ->press('Login');
226 | }
227 |
228 | protected function login_admin_user()
229 | {
230 | return $this->visit('login')
231 | ->type('admin@admin.com', 'email')
232 | ->type('sentryadmin', 'password')
233 | ->press('Login');
234 | }
235 |
236 |
237 | }
238 |
--------------------------------------------------------------------------------
/config/app.php:
--------------------------------------------------------------------------------
1 | env('APP_DEBUG'),
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Application URL
21 | |--------------------------------------------------------------------------
22 | |
23 | | This URL is used by the console to properly generate URLs when using
24 | | the Artisan command line tool. You should set this to the root of
25 | | your application so that it is used when running Artisan tasks.
26 | |
27 | */
28 |
29 | 'url' => 'http://localhost',
30 |
31 | /*
32 | |--------------------------------------------------------------------------
33 | | Application Timezone
34 | |--------------------------------------------------------------------------
35 | |
36 | | Here you may specify the default timezone for your application, which
37 | | will be used by the PHP date and date-time functions. We have gone
38 | | ahead and set this to a sensible default for you out of the box.
39 | |
40 | */
41 |
42 | 'timezone' => 'UTC',
43 |
44 | /*
45 | |--------------------------------------------------------------------------
46 | | Application Locale Configuration
47 | |--------------------------------------------------------------------------
48 | |
49 | | The application locale determines the default locale that will be used
50 | | by the translation service provider. You are free to set this value
51 | | to any of the locales which will be supported by the application.
52 | |
53 | */
54 |
55 | 'locale' => 'en',
56 |
57 | /*
58 | |--------------------------------------------------------------------------
59 | | Application Fallback Locale
60 | |--------------------------------------------------------------------------
61 | |
62 | | The fallback locale determines the locale to use when the current one
63 | | is not available. You may change the value to correspond to any of
64 | | the language folders that are provided through your application.
65 | |
66 | */
67 |
68 | 'fallback_locale' => 'en',
69 |
70 | /*
71 | |--------------------------------------------------------------------------
72 | | Encryption Key
73 | |--------------------------------------------------------------------------
74 | |
75 | | This key is used by the Illuminate encrypter service and should be set
76 | | to a random, 32 character string, otherwise these encrypted strings
77 | | will not be safe. Please do this before deploying an application!
78 | |
79 | */
80 |
81 | 'key' => env('APP_KEY', 'SomeRandomString'),
82 |
83 | 'cipher' => 'AES-256-CBC',
84 |
85 | /*
86 | |--------------------------------------------------------------------------
87 | | Logging Configuration
88 | |--------------------------------------------------------------------------
89 | |
90 | | Here you may configure the log settings for your application. Out of
91 | | the box, Laravel uses the Monolog PHP logging library. This gives
92 | | you a variety of powerful log handlers / formatters to utilize.
93 | |
94 | | Available Settings: "single", "daily", "syslog", "errorlog"
95 | |
96 | */
97 |
98 | 'log' => 'single',
99 |
100 | /*
101 | |--------------------------------------------------------------------------
102 | | Autoloaded Service Providers
103 | |--------------------------------------------------------------------------
104 | |
105 | | The service providers listed here will be automatically loaded on the
106 | | request to your application. Feel free to add your own services to
107 | | this array to grant expanded functionality to your applications.
108 | |
109 | */
110 |
111 | 'providers' => [
112 |
113 | /*
114 | * Laravel Framework Service Providers...
115 | */
116 | Illuminate\Foundation\Providers\ArtisanServiceProvider::class,
117 | Illuminate\Auth\AuthServiceProvider::class,
118 | Illuminate\Broadcasting\BroadcastServiceProvider::class,
119 | Illuminate\Bus\BusServiceProvider::class,
120 | Illuminate\Cache\CacheServiceProvider::class,
121 | Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
122 | Illuminate\Routing\ControllerServiceProvider::class,
123 | Illuminate\Cookie\CookieServiceProvider::class,
124 | Illuminate\Database\DatabaseServiceProvider::class,
125 | Illuminate\Encryption\EncryptionServiceProvider::class,
126 | Illuminate\Filesystem\FilesystemServiceProvider::class,
127 | Illuminate\Foundation\Providers\FoundationServiceProvider::class,
128 | Illuminate\Hashing\HashServiceProvider::class,
129 | Illuminate\Mail\MailServiceProvider::class,
130 | Illuminate\Pagination\PaginationServiceProvider::class,
131 | Illuminate\Pipeline\PipelineServiceProvider::class,
132 | Illuminate\Queue\QueueServiceProvider::class,
133 | Illuminate\Redis\RedisServiceProvider::class,
134 | Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
135 | Illuminate\Session\SessionServiceProvider::class,
136 | Illuminate\Translation\TranslationServiceProvider::class,
137 | Illuminate\Validation\ValidationServiceProvider::class,
138 | Illuminate\View\ViewServiceProvider::class,
139 |
140 | /*
141 | * Application Service Providers...
142 | */
143 | App\Providers\AppServiceProvider::class,
144 | App\Providers\EventServiceProvider::class,
145 | App\Providers\RouteServiceProvider::class,
146 | App\Providers\BackendServiceProvider::class,
147 |
148 | Cartalyst\Sentry\SentryServiceProvider::class,
149 | Illuminate\Html\HtmlServiceProvider::class,
150 |
151 | ],
152 |
153 | /*
154 | |--------------------------------------------------------------------------
155 | | Class Aliases
156 | |--------------------------------------------------------------------------
157 | |
158 | | This array of class aliases will be registered when this application
159 | | is started. However, feel free to register as many as you wish as
160 | | the aliases are "lazy" loaded so they don't hinder performance.
161 | |
162 | */
163 |
164 | 'aliases' => [
165 |
166 | 'App' => Illuminate\Support\Facades\App::class,
167 | 'Artisan' => Illuminate\Support\Facades\Artisan::class,
168 | 'Auth' => Illuminate\Support\Facades\Auth::class,
169 | 'Blade' => Illuminate\Support\Facades\Blade::class,
170 | 'Bus' => Illuminate\Support\Facades\Bus::class,
171 | 'Cache' => Illuminate\Support\Facades\Cache::class,
172 | 'Config' => Illuminate\Support\Facades\Config::class,
173 | 'Cookie' => Illuminate\Support\Facades\Cookie::class,
174 | 'Crypt' => Illuminate\Support\Facades\Crypt::class,
175 | 'DB' => Illuminate\Support\Facades\DB::class,
176 | 'Eloquent' => Illuminate\Database\Eloquent\Model::class,
177 | 'Event' => Illuminate\Support\Facades\Event::class,
178 | 'File' => Illuminate\Support\Facades\File::class,
179 | 'Hash' => Illuminate\Support\Facades\Hash::class,
180 | 'Input' => Illuminate\Support\Facades\Input::class,
181 | 'Inspiring' => Illuminate\Foundation\Inspiring::class,
182 | 'Lang' => Illuminate\Support\Facades\Lang::class,
183 | 'Log' => Illuminate\Support\Facades\Log::class,
184 | 'Mail' => Illuminate\Support\Facades\Mail::class,
185 | 'Password' => Illuminate\Support\Facades\Password::class,
186 | 'Queue' => Illuminate\Support\Facades\Queue::class,
187 | 'Redirect' => Illuminate\Support\Facades\Redirect::class,
188 | 'Redis' => Illuminate\Support\Facades\Redis::class,
189 | 'Request' => Illuminate\Support\Facades\Request::class,
190 | 'Response' => Illuminate\Support\Facades\Response::class,
191 | 'Route' => Illuminate\Support\Facades\Route::class,
192 | 'Schema' => Illuminate\Support\Facades\Schema::class,
193 | 'Session' => Illuminate\Support\Facades\Session::class,
194 | 'Storage' => Illuminate\Support\Facades\Storage::class,
195 | 'URL' => Illuminate\Support\Facades\URL::class,
196 | 'Validator' => Illuminate\Support\Facades\Validator::class,
197 | 'View' => Illuminate\Support\Facades\View::class,
198 |
199 | 'Sentry' => Cartalyst\Sentry\Facades\Laravel\Sentry::class,
200 | 'Form'=> Illuminate\Html\FormFacade::class,
201 | 'HTML'=> Illuminate\Html\HtmlFacade::class,
202 |
203 | ],
204 |
205 | ];
206 |
--------------------------------------------------------------------------------