Skip to content

Commit

Permalink
Merge pull request #7 from anindya-dhruba/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
anindya-dhruba authored Jan 7, 2018
2 parents 0c75aaa + 5f6a337 commit 9209045
Show file tree
Hide file tree
Showing 85 changed files with 14,085 additions and 55,591 deletions.
7 changes: 6 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
APP_NAME="Laravel Vue SPA"
APP_ENV=local
APP_KEY=
APP_DEBUG=true
Expand All @@ -11,17 +12,20 @@ DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret

JWT_SECRET=yourJwtSecretCodeGoesHere

BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_LIFETIME=120
QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
Expand All @@ -30,3 +34,4 @@ MAIL_ENCRYPTION=null
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
* text=auto
*.css linguist-vendored
*.scss linguist-vendored
*.js linguist-vendored
CHANGELOG.md export-ignore
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
/node_modules
/public/storage
/public/hot
/public/storage
/storage/*.key
/vendor
/.idea
/.vagrant
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
.env
.DS_Store
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2017 Anindya Dhruba
Copyright (c) 2018 Anindya Dhruba

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
1 change: 0 additions & 1 deletion Procfile

This file was deleted.

4 changes: 3 additions & 1 deletion app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ protected function schedule(Schedule $schedule)
}

/**
* Register the Closure based commands for the application.
* Register the commands for the application.
*
* @return void
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');

require base_path('routes/console.php');
}
}
36 changes: 12 additions & 24 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,27 @@
namespace App\Exceptions;

use Exception;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;

class Handler extends ExceptionHandler
{
/**
* A list of the exception types that should not be reported.
* A list of the exception types that are not reported.
*
* @var array
*/
protected $dontReport = [
\Illuminate\Auth\AuthenticationException::class,
\Illuminate\Auth\Access\AuthorizationException::class,
\Symfony\Component\HttpKernel\Exception\HttpException::class,
\Illuminate\Database\Eloquent\ModelNotFoundException::class,
\Illuminate\Session\TokenMismatchException::class,
\Illuminate\Validation\ValidationException::class,
//
];

/**
* A list of the inputs that are never flashed for validation exceptions.
*
* @var array
*/
protected $dontFlash = [
'password',
'password_confirmation',
];

/**
Expand All @@ -46,20 +50,4 @@ public function render($request, Exception $exception)
{
return parent::render($request, $exception);
}

/**
* Convert an authentication exception into an unauthenticated response.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Auth\AuthenticationException $exception
* @return \Illuminate\Http\Response
*/
protected function unauthenticated($request, AuthenticationException $exception)
{
if ($request->expectsJson()) {
return response()->json(['error' => 'Unauthenticated.'], 401);
}

return redirect()->guest(route('login'));
}
}
2 changes: 1 addition & 1 deletion app/Http/Controllers/Auth/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ class LoginController extends Controller
*/
public function __construct()
{
$this->middleware('guest', ['except' => 'logout']);
$this->middleware('guest')->except('logout');
}
}
8 changes: 4 additions & 4 deletions app/Http/Controllers/Auth/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,17 @@ public function __construct()
protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|min:6|confirmed',
'name' => 'required|string|max:255',
'email' => 'required|string|email|max:255|unique:users',
'password' => 'required|string|min:6|confirmed',
]);
}

/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return User
* @return \App\User
*/
protected function create(array $data)
{
Expand Down
44 changes: 23 additions & 21 deletions app/Http/Controllers/AuthenticateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,27 @@

class AuthenticateController extends Controller
{
public function authenticate(Request $request)
{
$rules = [
'email' => 'required|email',
'password' => 'required'
];

$this->validate($request, $rules);

$credentials = $request->only('email', 'password');

try {
if (! $token = JWTAuth::attempt($credentials)) {
return response()->json(['error' => 'Invalid Login Credential'], 401);
}
} catch (JWTException $e) {
return response()->json(['error' => 'Could not create token'], 500);
}

return response()->json(compact('token'));
}
public function authenticate(Request $request)
{
$rules = [
'email' => 'required|email',
'password' => 'required'
];

$this->validate($request, $rules);

$credentials = $request->only('email', 'password');

try {
if(!$token = JWTAuth::attempt($credentials)) {
return response()->json(['error' => 'Invalid Login Credential'], 401);
}
} catch(JWTException $e) {
return response()->json(['error' => 'Could not create token'], 500);
}

$user = $request->user();

return response()->json(compact('token', 'user'));
}
}
74 changes: 37 additions & 37 deletions app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,41 @@

class UserController extends Controller
{
public function show(Request $request)
{
return $request->user();
}
public function updateProfile(Request $request)
{
$rules = [
'name' => 'required',
'email' => 'required|email|',
];

$this->validate($request, $rules);
$user = $request->user();
$user->name = $request->input('name');
$user->email = $request->input('email');
$user->save();

return response()->json(compact('user'));
}

public function updatePassword(Request $request)
{
$rules = [
'new_password' => 'required',
'confirm_new_password' => 'required|same:new_password'
];

$this->validate($request, $rules);

$user = $request->user();
$user->password = bcrypt($request->input('new_password'));
$user->saveOrFail();

return response()->json(compact('user'));
}
public function show(Request $request)
{
return $request->user();
}

public function updateProfile(Request $request)
{
$rules = [
'name' => 'required',
'email' => 'required|email|',
];

$this->validate($request, $rules);

$user = $request->user();
$user->name = $request->input('name');
$user->email = $request->input('email');
$user->save();

return response()->json(compact('user'));
}

public function updatePassword(Request $request)
{
$rules = [
'new_password' => 'required',
'confirm_new_password' => 'required|same:new_password'
];

$this->validate($request, $rules);

$user = $request->user();
$user->password = bcrypt($request->input('new_password'));
$user->saveOrFail();

return response()->json(compact('user'));
}
}
1 change: 1 addition & 0 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Kernel extends HttpKernel
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
\App\Http\Middleware\TrustProxies::class,
];

/**
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Middleware/EncryptCookies.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace App\Http\Middleware;

use Illuminate\Cookie\Middleware\EncryptCookies as BaseEncrypter;
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;

class EncryptCookies extends BaseEncrypter
class EncryptCookies extends Middleware
{
/**
* The names of the cookies that should not be encrypted.
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Middleware/TrimStrings.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace App\Http\Middleware;

use Illuminate\Foundation\Http\Middleware\TrimStrings as BaseTrimmer;
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;

class TrimStrings extends BaseTrimmer
class TrimStrings extends Middleware
{
/**
* The names of the attributes that should not be trimmed.
Expand Down
29 changes: 29 additions & 0 deletions app/Http/Middleware/TrustProxies.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace App\Http\Middleware;

use Illuminate\Http\Request;
use Fideloper\Proxy\TrustProxies as Middleware;

class TrustProxies extends Middleware
{
/**
* The trusted proxies for this application.
*
* @var array
*/
protected $proxies;

/**
* The current proxy header mappings.
*
* @var array
*/
protected $headers = [
Request::HEADER_FORWARDED => 'FORWARDED',
Request::HEADER_X_FORWARDED_FOR => 'X_FORWARDED_FOR',
Request::HEADER_X_FORWARDED_HOST => 'X_FORWARDED_HOST',
Request::HEADER_X_FORWARDED_PORT => 'X_FORWARDED_PORT',
Request::HEADER_X_FORWARDED_PROTO => 'X_FORWARDED_PROTO',
];
}
4 changes: 2 additions & 2 deletions app/Http/Middleware/VerifyCsrfToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace App\Http\Middleware;

use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;

class VerifyCsrfToken extends BaseVerifier
class VerifyCsrfToken extends Middleware
{
/**
* The URIs that should be excluded from CSRF verification.
Expand Down
2 changes: 1 addition & 1 deletion app/Providers/EventServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class EventServiceProvider extends ServiceProvider
* @var array
*/
protected $listen = [
'App\Events\SomeEvent' => [
'App\Events\Event' => [
'App\Listeners\EventListener',
],
];
Expand Down
Loading

0 comments on commit 9209045

Please sign in to comment.