Skip to content
This repository was archived by the owner on Jun 11, 2019. It is now read-only.

Commit ee5c028

Browse files
committed
Minimal worked vversion
1 parent 63201a8 commit ee5c028

40 files changed

+1558
-44
lines changed

api/.env.example

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
APP_NAME=Laravel
1+
APP_NAME=API
22
APP_ENV=local
33
APP_KEY=base64:mOG4234B2AMlOmTGs50Pq04eUkk0btY7vxZPAfdIKLQ=
44
APP_DEBUG=true
55
APP_LOG_LEVEL=debug
6-
APP_URL=http://localhost
6+
APP_URL=https://auth.127.0.0.1.xip.io
77

88
DB_CONNECTION=mysql
99
DB_HOST=db.local
1010
DB_PORT=3306
11-
DB_DATABASE=oauth2
11+
DB_DATABASE=auth
1212
DB_USERNAME=root
1313
DB_PASSWORD=secret
1414

api/app/Console/Kernel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Api\Console;
3+
namespace App\Console;
44

55
use Illuminate\Console\Scheduling\Schedule;
66
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

api/app/Exceptions/Handler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Api\Exceptions;
3+
namespace App\Exceptions;
44

55
use Exception;
66
use Illuminate\Auth\AuthenticationException;

api/app/Http/Controllers/Auth/ForgotPasswordController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22

3-
namespace Api\Http\Controllers\Auth;
3+
namespace App\Http\Controllers\Auth;
44

5-
use Api\Http\Controllers\Controller;
5+
use App\Http\Controllers\Controller;
66
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
77

88
class ForgotPasswordController extends Controller

api/app/Http/Controllers/Auth/LoginController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22

3-
namespace Api\Http\Controllers\Auth;
3+
namespace App\Http\Controllers\Auth;
44

5-
use Api\Http\Controllers\Controller;
5+
use App\Http\Controllers\Controller;
66
use Illuminate\Foundation\Auth\AuthenticatesUsers;
77

88
class LoginController extends Controller

api/app/Http/Controllers/Auth/RegisterController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php
22

3-
namespace Api\Http\Controllers\Auth;
3+
namespace App\Http\Controllers\Auth;
44

5-
use Api\User;
6-
use Api\Http\Controllers\Controller;
5+
use App\User;
6+
use App\Http\Controllers\Controller;
77
use Illuminate\Support\Facades\Validator;
88
use Illuminate\Foundation\Auth\RegistersUsers;
99

@@ -58,7 +58,7 @@ protected function validator(array $data)
5858
* Create a new user instance after a valid registration.
5959
*
6060
* @param array $data
61-
* @return \Api\User
61+
* @return \App\User
6262
*/
6363
protected function create(array $data)
6464
{

api/app/Http/Controllers/Auth/ResetPasswordController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22

3-
namespace Api\Http\Controllers\Auth;
3+
namespace App\Http\Controllers\Auth;
44

5-
use Api\Http\Controllers\Controller;
5+
use App\Http\Controllers\Controller;
66
use Illuminate\Foundation\Auth\ResetsPasswords;
77

88
class ResetPasswordController extends Controller

api/app/Http/Controllers/Controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Api\Http\Controllers;
3+
namespace App\Http\Controllers;
44

55
use Illuminate\Foundation\Bus\DispatchesJobs;
66
use Illuminate\Routing\Controller as BaseController;

api/app/Http/Kernel.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Api\Http;
3+
namespace App\Http;
44

55
use Illuminate\Foundation\Http\Kernel as HttpKernel;
66

@@ -16,6 +16,7 @@ class Kernel extends HttpKernel
1616
protected $middleware = [
1717
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
1818
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
19+
\App\Http\Middleware\TrimStrings::class,
1920
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
2021
];
2122

@@ -25,6 +26,16 @@ class Kernel extends HttpKernel
2526
* @var array
2627
*/
2728
protected $middlewareGroups = [
29+
'web' => [
30+
\App\Http\Middleware\EncryptCookies::class,
31+
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
32+
\Illuminate\Session\Middleware\StartSession::class,
33+
// \Illuminate\Session\Middleware\AuthenticateSession::class,
34+
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
35+
\App\Http\Middleware\VerifyCsrfToken::class,
36+
\Illuminate\Routing\Middleware\SubstituteBindings::class,
37+
],
38+
2839
'api' => [
2940
'throttle:60,1',
3041
'bindings',
@@ -40,7 +51,10 @@ class Kernel extends HttpKernel
4051
*/
4152
protected $routeMiddleware = [
4253
'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
54+
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
4355
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
56+
'can' => \Illuminate\Auth\Middleware\Authorize::class,
57+
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
4458
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
4559
];
4660
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace App\Http\Middleware;
4+
5+
use Illuminate\Cookie\Middleware\EncryptCookies as BaseEncrypter;
6+
7+
class EncryptCookies extends BaseEncrypter
8+
{
9+
/**
10+
* The names of the cookies that should not be encrypted.
11+
*
12+
* @var array
13+
*/
14+
protected $except = [
15+
//
16+
];
17+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace App\Http\Middleware;
4+
5+
use Closure;
6+
use Illuminate\Support\Facades\Auth;
7+
8+
class RedirectIfAuthenticated
9+
{
10+
/**
11+
* Handle an incoming request.
12+
*
13+
* @param \Illuminate\Http\Request $request
14+
* @param \Closure $next
15+
* @param string|null $guard
16+
* @return mixed
17+
*/
18+
public function handle($request, Closure $next, $guard = null)
19+
{
20+
if (Auth::guard($guard)->check()) {
21+
return redirect('/home');
22+
}
23+
24+
return $next($request);
25+
}
26+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace App\Http\Middleware;
4+
5+
use Illuminate\Foundation\Http\Middleware\TrimStrings as BaseTrimmer;
6+
7+
class TrimStrings extends BaseTrimmer
8+
{
9+
/**
10+
* The names of the attributes that should not be trimmed.
11+
*
12+
* @var array
13+
*/
14+
protected $except = [
15+
'password',
16+
'password_confirmation',
17+
];
18+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace App\Http\Middleware;
4+
5+
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;
6+
7+
class VerifyCsrfToken extends BaseVerifier
8+
{
9+
/**
10+
* The URIs that should be excluded from CSRF verification.
11+
*
12+
* @var array
13+
*/
14+
protected $except = [
15+
//
16+
];
17+
}

api/app/Providers/AppServiceProvider.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?php
22

3-
namespace Api\Providers;
3+
namespace App\Providers;
44

55
use Illuminate\Support\ServiceProvider;
6+
use Laravel\Passport\Passport;
67

78
class AppServiceProvider extends ServiceProvider
89
{
@@ -23,6 +24,6 @@ public function boot()
2324
*/
2425
public function register()
2526
{
26-
//
27+
Passport::ignoreMigrations();
2728
}
2829
}

api/app/Providers/AuthServiceProvider.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<?php
22

3-
namespace Api\Providers;
3+
namespace App\Providers;
44

55
use Illuminate\Support\Facades\Gate;
66
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
7+
use Laravel\Passport\Passport;
78

89
class AuthServiceProvider extends ServiceProvider
910
{
@@ -24,5 +25,7 @@ class AuthServiceProvider extends ServiceProvider
2425
public function boot()
2526
{
2627
$this->registerPolicies();
28+
29+
// Passport::routes();
2730
}
2831
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace App\Providers;
4+
5+
use Illuminate\Support\ServiceProvider;
6+
use Illuminate\Support\Facades\Broadcast;
7+
8+
class BroadcastServiceProvider extends ServiceProvider
9+
{
10+
/**
11+
* Bootstrap any application services.
12+
*
13+
* @return void
14+
*/
15+
public function boot()
16+
{
17+
Broadcast::routes();
18+
19+
require base_path('routes/channels.php');
20+
}
21+
}

api/app/Providers/EventServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Api\Providers;
3+
namespace App\Providers;
44

55
use Illuminate\Support\Facades\Event;
66
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;

api/app/Providers/RouteServiceProvider.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Api\Providers;
3+
namespace App\Providers;
44

55
use Illuminate\Support\Facades\Route;
66
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
@@ -36,9 +36,11 @@ public function boot()
3636
public function map()
3737
{
3838
$this->mapApiRoutes();
39+
3940
}
4041

4142

43+
4244
/**
4345
* Define the "api" routes for the application.
4446
*

api/app/User.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
<?php
22

3-
namespace Api;
3+
namespace App;
44

5-
class User
5+
use Illuminate\Notifications\Notifiable;
6+
use Illuminate\Foundation\Auth\User as Authenticatable;
7+
use Laravel\Passport\HasApiTokens;
8+
9+
class User extends Authenticatable
610
{
7-
use Notifiable;
11+
use HasApiTokens, Notifiable;
812

913
/**
1014
* The attributes that are mass assignable.

api/bootstrap/app.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@
2828

2929
$app->singleton(
3030
Illuminate\Contracts\Http\Kernel::class,
31-
Api\Http\Kernel::class
31+
App\Http\Kernel::class
3232
);
3333

3434
$app->singleton(
3535
Illuminate\Contracts\Console\Kernel::class,
36-
Api\Console\Kernel::class
36+
App\Console\Kernel::class
3737
);
3838

3939
$app->singleton(
4040
Illuminate\Contracts\Debug\ExceptionHandler::class,
41-
Api\Exceptions\Handler::class
41+
App\Exceptions\Handler::class
4242
);
4343

4444
/*

api/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"require": {
88
"php": ">=5.6.4",
99
"laravel/framework": "5.4.*",
10+
"laravel/passport": "^3.0",
1011
"laravel/tinker": "~1.0"
1112
},
1213
"require-dev": {
@@ -19,7 +20,7 @@
1920
"database"
2021
],
2122
"psr-4": {
22-
"Api\\": "app/"
23+
"App\\": "app/"
2324
}
2425
},
2526
"autoload-dev": {

0 commit comments

Comments
 (0)