diff --git a/app/Http/Controllers/AuthController.php b/app/Http/Controllers/AuthController.php index 4db9454c..cabb1ca7 100644 --- a/app/Http/Controllers/AuthController.php +++ b/app/Http/Controllers/AuthController.php @@ -1,5 +1,6 @@ $request->name, + 'email' => $request->email, + 'password' => bcrypt($request->password), + ]); $this->auth->login($user); - return redirect('/'); + return redirect('/dashboard'); } /** @@ -72,12 +77,14 @@ public function postLogin(LoginRequest $request) { if ($this->auth->attempt($request->only('email', 'password'))) { - return redirect('/'); + return redirect('/dashboard'); } - return redirect('/auth/login')->withErrors([ - 'email' => 'These credentials do not match our records.', - ]); + return redirect('/auth/login') + ->withInput($request->only('email')) + ->withErrors([ + 'email' => 'These credentials do not match our records.', + ]); } /** diff --git a/app/Http/Controllers/DashboardController.php b/app/Http/Controllers/DashboardController.php new file mode 100644 index 00000000..c280f453 --- /dev/null +++ b/app/Http/Controllers/DashboardController.php @@ -0,0 +1,25 @@ +middleware('auth'); + } + + /** + * Show the application dashboard to the user. + * + * @return Response + */ + public function index() + { + return view('dashboard'); + } + +} diff --git a/app/Http/Controllers/PasswordController.php b/app/Http/Controllers/PasswordController.php index ea582e48..4b3ce312 100644 --- a/app/Http/Controllers/PasswordController.php +++ b/app/Http/Controllers/PasswordController.php @@ -1,11 +1,20 @@ auth = $auth; $this->passwords = $passwords; $this->middleware('guest'); @@ -33,7 +43,7 @@ public function __construct(PasswordBroker $passwords) */ public function getEmail() { - return view('password.email'); + return view('auth.password'); } /** @@ -44,6 +54,8 @@ public function getEmail() */ public function postEmail(Request $request) { + $this->validate($request, ['email' => 'required']); + switch ($response = $this->passwords->sendResetLink($request->only('email'))) { case PasswordBroker::INVALID_USER: @@ -67,7 +79,7 @@ public function getReset($token = null) throw new NotFoundHttpException; } - return view('password.reset')->with('token', $token); + return view('auth.reset')->with('token', $token); } /** @@ -94,11 +106,26 @@ public function postReset(Request $request) case PasswordBroker::INVALID_PASSWORD: case PasswordBroker::INVALID_TOKEN: case PasswordBroker::INVALID_USER: - return redirect()->back()->withErrors(['email' => trans($response)]); + return redirect()->back() + ->withInput($request->only('email')) + ->withErrors(['email' => trans($response)]); case PasswordBroker::PASSWORD_RESET: - return redirect()->to('/'); + return $this->loginAndRedirect($request->email); } } + /** + * Login the user with the given e-mail address and redirect home. + * + * @param string $email + * @return Response + */ + protected function loginAndRedirect($email) + { + $this->auth->login(User::where('email', $email)->firstOrFail()); + + return redirect('/dashboard'); + } + } diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/WelcomeController.php similarity index 80% rename from app/Http/Controllers/HomeController.php rename to app/Http/Controllers/WelcomeController.php index b4170b0e..e468e41d 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/WelcomeController.php @@ -1,6 +1,6 @@ get('/', 'HomeController@showWelcome'); + | $router->get('/', 'WelcomeController@index'); | */ public function index() { - return view('hello'); + return view('welcome'); } } diff --git a/app/Http/Requests/RegisterRequest.php b/app/Http/Requests/RegisterRequest.php index 7504f152..1d7a03dd 100644 --- a/app/Http/Requests/RegisterRequest.php +++ b/app/Http/Requests/RegisterRequest.php @@ -10,7 +10,8 @@ class RegisterRequest extends Request { public function rules() { return [ - 'email' => 'required|email|unique:users', + 'name' => 'required|max:255', + 'email' => 'required|max:255|email|unique:users', 'password' => 'required|confirmed|min:8', ]; } diff --git a/app/Http/routes.php b/app/Http/routes.php index dc0e0796..3486e3ab 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -11,7 +11,9 @@ | */ -$router->get('/', 'HomeController@index'); +$router->get('/', 'WelcomeController@index'); + +$router->get('/dashboard', 'DashboardController@index'); /* |-------------------------------------------------------------------------- diff --git a/bower.json b/bower.json index ddb71b18..f5251fb0 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,7 @@ { "name": "Laravel Application", "dependencies": { - "bootstrap-sass-official": "~3.3.1" + "bootstrap-sass-official": "~3.3.1", + "font-awesome": "~4.2.0" } } diff --git a/config/local/mail.php b/config/local/mail.php new file mode 100644 index 00000000..c4fac1d0 --- /dev/null +++ b/config/local/mail.php @@ -0,0 +1,98 @@ + 'smtp', + + /* + |-------------------------------------------------------------------------- + | SMTP Host Address + |-------------------------------------------------------------------------- + | + | Here you may provide the host address of the SMTP server used by your + | applications. A default option is provided that is compatible with + | the Mailgun mail service which will provide reliable deliveries. + | + */ + + 'host' => 'mailtrap.io', + + /* + |-------------------------------------------------------------------------- + | SMTP Host Port + |-------------------------------------------------------------------------- + | + | This is the SMTP port used by your application to deliver e-mails to + | users of the application. Like the host we have set this value to + | stay compatible with the Mailgun e-mail application by default. + | + */ + + 'port' => 465, + + /* + |-------------------------------------------------------------------------- + | Global "From" Address + |-------------------------------------------------------------------------- + | + | You may wish for all e-mails sent by your application to be sent from + | the same address. Here, you may specify a name and address that is + | used globally for all e-mails that are sent by your application. + | + */ + + 'from' => ['address' => 'homestead@laravel.com', 'name' => 'Homestead'], + + /* + |-------------------------------------------------------------------------- + | E-Mail Encryption Protocol + |-------------------------------------------------------------------------- + | + | Here you may specify the encryption protocol that should be used when + | the application send e-mail messages. A sensible default using the + | transport layer security protocol should provide great security. + | + */ + + 'encryption' => 'tls', + + /* + |-------------------------------------------------------------------------- + | SMTP Server Username + |-------------------------------------------------------------------------- + | + | If your SMTP server requires a username for authentication, you should + | set it here. This will get used to authenticate with your server on + | connection. You may also set the "password" value below this one. + | + */ + + 'username' => '', + + /* + |-------------------------------------------------------------------------- + | SMTP Server Password + |-------------------------------------------------------------------------- + | + | Here you may set the password required by your SMTP server to send out + | messages from your application. This will be given to the server on + | connection so that the application will be able to send messages. + | + */ + + 'password' => '', + +]; diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.php index bbe3db32..36a1db9b 100644 --- a/database/migrations/2014_10_12_000000_create_users_table.php +++ b/database/migrations/2014_10_12_000000_create_users_table.php @@ -15,6 +15,7 @@ public function up() Schema::create('users', function(Blueprint $table) { $table->increments('id'); + $table->string('name'); $table->string('email')->unique(); $table->string('password', 60); $table->rememberToken(); diff --git a/gulpfile.js b/gulpfile.js index 4940a4a8..aba846bf 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -13,6 +13,20 @@ var elixir = require('laravel-elixir'); elixir(function(mix) { mix.sass("app.scss") - .phpUnit() - .publish("vendor/bower_components"); + .publish( + 'jquery/dist/jquery.min.js', + 'public/js/vendor/jquery.js' + ) + .publish( + 'bootstrap-sass-official/assets/javascripts/bootstrap.js', + 'public/js/vendor/bootstrap.js' + ) + .publish( + 'font-awesome/css/font-awesome.min.css', + 'public/css/vendor/font-awesome.css' + ) + .publish( + 'font-awesome/fonts', + 'public/css/vendor/fonts' + ); }); diff --git a/resources/assets/.gitkeep b/resources/assets/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/resources/assets/sass/app.scss b/resources/assets/sass/app.scss index cbd46a7a..0ceaa06f 100644 --- a/resources/assets/sass/app.scss +++ b/resources/assets/sass/app.scss @@ -1 +1,9 @@ +$font-family-sans-serif: "Lato", Helvetica, Arial, sans-serif; + @import "bootstrap"; +@import "partials/auth"; +@import "partials/navigation"; + +.fa-btn { + margin-right: 10px; +} diff --git a/resources/assets/sass/partials/_auth.scss b/resources/assets/sass/partials/_auth.scss new file mode 100644 index 00000000..d4c99438 --- /dev/null +++ b/resources/assets/sass/partials/_auth.scss @@ -0,0 +1,4 @@ +.forgot-password { + padding-top: 7px; + vertical-align: middle; +} diff --git a/resources/assets/sass/partials/_navigation.scss b/resources/assets/sass/partials/_navigation.scss new file mode 100644 index 00000000..a1bea470 --- /dev/null +++ b/resources/assets/sass/partials/_navigation.scss @@ -0,0 +1,5 @@ +.navbar-avatar { + border-radius: 999px; + margin: -11px 10px -10px 0; + padding: 0; +} diff --git a/resources/lang/en/passwords.php b/resources/lang/en/passwords.php index 31b68c09..2e966d00 100644 --- a/resources/lang/en/passwords.php +++ b/resources/lang/en/passwords.php @@ -19,7 +19,7 @@ "token" => "This password reset token is invalid.", - "sent" => "Password reminder sent!", + "sent" => "Password reset link sent!", "reset" => "Password has been reset!", diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php new file mode 100644 index 00000000..e15df423 --- /dev/null +++ b/resources/views/auth/login.blade.php @@ -0,0 +1,49 @@ +@extends('layouts.app') + +@section('content') +