Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ryan Thompson
committed
Oct 21, 2014
1 parent
73276b9
commit 789281b
Showing
31 changed files
with
886 additions
and
13,960 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php namespace App\Console\Commands; | ||
|
||
use Illuminate\Console\Command; | ||
use Illuminate\Foundation\Inspiring; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
|
||
class InspireCommand extends Command { | ||
|
||
/** | ||
* The console command name. | ||
* | ||
* @var string | ||
*/ | ||
protected $name = 'inspire'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Display an inspiring quote'; | ||
|
||
/** | ||
* Create a new command instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
} | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return mixed | ||
*/ | ||
public function fire() | ||
{ | ||
$this->comment(PHP_EOL.Inspiring::quote().PHP_EOL); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php namespace App\Console; | ||
|
||
use Exception; | ||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel; | ||
|
||
class Kernel extends ConsoleKernel { | ||
|
||
/** | ||
* Run the console application. | ||
* | ||
* @param \Symfony\Component\Console\Input\InputInterface $input | ||
* @param \Symfony\Component\Console\Output\OutputInterface $output | ||
* @return int | ||
*/ | ||
public function handle($input, $output = null) | ||
{ | ||
try | ||
{ | ||
return parent::handle($input, $output); | ||
} | ||
catch (Exception $e) | ||
{ | ||
$output->writeln((string) $e); | ||
|
||
return 1; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<?php namespace App\Http\Controllers\Auth; | ||
|
||
use Illuminate\Routing\Controller; | ||
use Illuminate\Contracts\Auth\Guard; | ||
use App\Http\Requests\Auth\LoginRequest; | ||
use App\Http\Requests\Auth\RegisterRequest; | ||
|
||
/** | ||
* @Middleware("guest", except={"logout"}) | ||
*/ | ||
class AuthController extends Controller { | ||
|
||
/** | ||
* The Guard implementation. | ||
* | ||
* @var Guard | ||
*/ | ||
protected $auth; | ||
|
||
/** | ||
* Create a new authentication controller instance. | ||
* | ||
* @param Guard $auth | ||
* @return void | ||
*/ | ||
public function __construct(Guard $auth) | ||
{ | ||
$this->auth = $auth; | ||
} | ||
|
||
/** | ||
* Show the application registration form. | ||
* | ||
* @Get("auth/register") | ||
* | ||
* @return Response | ||
*/ | ||
public function showRegistrationForm() | ||
{ | ||
return view('auth.register'); | ||
} | ||
|
||
/** | ||
* Handle a registration request for the application. | ||
* | ||
* @Post("auth/register") | ||
* | ||
* @param RegisterRequest $request | ||
* @return Response | ||
*/ | ||
public function register(RegisterRequest $request) | ||
{ | ||
// Registration form is valid, create user... | ||
|
||
$this->auth->login($user); | ||
|
||
return redirect('/'); | ||
} | ||
|
||
/** | ||
* Show the application login form. | ||
* | ||
* @Get("auth/login") | ||
* | ||
* @return Response | ||
*/ | ||
public function showLoginForm() | ||
{ | ||
return view('auth.login'); | ||
} | ||
|
||
/** | ||
* Handle a login request to the application. | ||
* | ||
* @Post("auth/login") | ||
* | ||
* @param LoginRequest $request | ||
* @return Response | ||
*/ | ||
public function login(LoginRequest $request) | ||
{ | ||
if ($this->auth->attempt($request->only('email', 'password'))) | ||
{ | ||
return redirect('/'); | ||
} | ||
|
||
return redirect('/auth/login')->withErrors([ | ||
'email' => 'These credentials do not match our records.', | ||
]); | ||
} | ||
|
||
/** | ||
* Log the user out of the application. | ||
* | ||
* @Get("auth/logout") | ||
* | ||
* @return Response | ||
*/ | ||
public function logout() | ||
{ | ||
$this->auth->logout(); | ||
|
||
return redirect('/'); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
<?php namespace App\Http\Controllers\Auth; | ||
|
||
use Illuminate\Http\Request; | ||
use Illuminate\Routing\Controller; | ||
use Illuminate\Contracts\Auth\PasswordBroker; | ||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; | ||
|
||
/** | ||
* @Middleware("guest") | ||
*/ | ||
class PasswordController extends Controller { | ||
|
||
/** | ||
* The password broker implementation. | ||
* | ||
* @var PasswordBroker | ||
*/ | ||
protected $passwords; | ||
|
||
/** | ||
* Create a new password controller instance. | ||
* | ||
* @param PasswordBroker $passwords | ||
* @return void | ||
*/ | ||
public function __construct(PasswordBroker $passwords) | ||
{ | ||
$this->passwords = $passwords; | ||
} | ||
|
||
/** | ||
* Display the form to request a password reset link. | ||
* | ||
* @Get("password/email") | ||
* | ||
* @return Response | ||
*/ | ||
public function showResetRequestForm() | ||
{ | ||
return view('password.email'); | ||
} | ||
|
||
/** | ||
* Send a reset link to the given user. | ||
* | ||
* @Post("password/email") | ||
* | ||
* @param Request $request | ||
* @return Response | ||
*/ | ||
public function sendResetLink(Request $request) | ||
{ | ||
switch ($response = $this->passwords->sendResetLink($request->only('email'))) | ||
{ | ||
case PasswordBroker::INVALID_USER: | ||
return redirect()->back()->with('error', trans($response)); | ||
|
||
case PasswordBroker::RESET_LINK_SENT: | ||
return redirect()->back()->with('status', trans($response)); | ||
} | ||
} | ||
|
||
/** | ||
* Display the password reset view for the given token. | ||
* | ||
* @Get("password/reset") | ||
* | ||
* @param string $token | ||
* @return Response | ||
*/ | ||
public function showResetForm($token = null) | ||
{ | ||
if (is_null($token)) | ||
{ | ||
throw new NotFoundHttpException; | ||
} | ||
|
||
return view('password.reset')->with('token', $token); | ||
} | ||
|
||
/** | ||
* Reset the given user's password. | ||
* | ||
* @Post("password/reset") | ||
* | ||
* @param Request $request | ||
* @return Response | ||
*/ | ||
public function resetPassword(Request $request) | ||
{ | ||
$credentials = $request->only( | ||
'email', 'password', 'password_confirmation', 'token' | ||
); | ||
|
||
$response = $this->passwords->reset($credentials, function($user, $password) | ||
{ | ||
$user->password = bcrypt($password); | ||
|
||
$user->save(); | ||
}); | ||
|
||
switch ($response) | ||
{ | ||
case PasswordBroker::INVALID_PASSWORD: | ||
case PasswordBroker::INVALID_TOKEN: | ||
case PasswordBroker::INVALID_USER: | ||
return redirect()->back()->with('error', trans($response)); | ||
|
||
case PasswordBroker::PASSWORD_RESET: | ||
return redirect()->to('/'); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php namespace App\Http\Controllers; | ||
|
||
use Illuminate\Routing\Controller; | ||
|
||
class HomeController extends Controller { | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Home Controller | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Controller methods are called when a request enters the application | ||
| with their assigned URI. The URI a method responds to may be set | ||
| via simple annotations. Here is an example to get you started! | ||
| | ||
*/ | ||
|
||
/** | ||
* @Get("/") | ||
*/ | ||
public function index() | ||
{ | ||
return view('hello'); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php namespace App\Http; | ||
|
||
use Exception; | ||
use Illuminate\Foundation\Http\Kernel as HttpKernel; | ||
|
||
class Kernel extends HttpKernel { | ||
|
||
/** | ||
* The application's HTTP middleware stack. | ||
* | ||
* @var array | ||
*/ | ||
protected $middleware = [ | ||
'App\Http\Middleware\UnderMaintenance', | ||
'Illuminate\Cookie\Middleware\EncryptCookies', | ||
'Illuminate\Cookie\Middleware\AddQueuedCookiesToRequest', | ||
'Illuminate\Session\Middleware\ReadSession', | ||
'Illuminate\Session\Middleware\WriteSession', | ||
'Illuminate\View\Middleware\ShareErrorsFromSession', | ||
'App\Http\Middleware\CsrfTokenIsValid', | ||
]; | ||
|
||
/** | ||
* Handle an incoming HTTP request. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function handle($request) | ||
{ | ||
try | ||
{ | ||
return parent::handle($request); | ||
} | ||
catch (Exception $e) | ||
{ | ||
throw $e; | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.