From 5915f6f10cf7c4bc89c7ea07ddb084c67ed44d39 Mon Sep 17 00:00:00 2001 From: Burak Demirpolat <44942068+bdemirpolat@users.noreply.github.com> Date: Sat, 26 Jan 2019 21:27:56 +0300 Subject: [PATCH 01/16] Auth --- .env.example | 38 -------------------------------------- 1 file changed, 38 deletions(-) delete mode 100644 .env.example diff --git a/.env.example b/.env.example deleted file mode 100644 index d434cf7..0000000 --- a/.env.example +++ /dev/null @@ -1,38 +0,0 @@ -APP_NAME=dotCFP -APP_ENV=local -APP_KEY= -APP_DEBUG=true -APP_LOG_LEVEL=debug -APP_URL=http://localhost - -DB_CONNECTION=mysql -DB_HOST=127.0.0.1 -DB_PORT=3306 -DB_DATABASE=homestead -DB_USERNAME=homestead -DB_PASSWORD=secret - -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=smtp.mailtrap.io -MAIL_PORT=2525 -MAIL_USERNAME=null -MAIL_PASSWORD=null -MAIL_ENCRYPTION=null - -PUSHER_APP_ID= -PUSHER_APP_KEY= -PUSHER_APP_SECRET= - -GITHUB_CLIENT_ID= -GITHUB_CLIENT_SECRET= -GITHUB_CALLBACK_URL= From c54db58ae5c459c91dd454ffb96ee4abdf4fb053 Mon Sep 17 00:00:00 2001 From: Burak Demirpolat <44942068+bdemirpolat@users.noreply.github.com> Date: Sat, 26 Jan 2019 21:30:05 +0300 Subject: [PATCH 02/16] Auth Complete --- .../Auth/ForgotPasswordController.php | 32 +++++++ .../Controllers/Auth/RegisterController.php | 77 ++++++++++++++++ .../Auth/ResetPasswordController.php | 39 ++++++++ .../Auth/VerificationController.php | 41 +++++++++ app/Http/Controllers/LoginController.php | 2 +- app/Providers/AppServiceProvider.php | 3 +- app/User.php | 4 +- .../2014_10_12_000000_create_users_table.php | 3 +- public/css/app.css | 9 ++ resources/views/auth/login.blade.php | 72 +++++++++++++++ .../views/auth/passwords/email.blade.php | 46 ++++++++++ .../views/auth/passwords/reset.blade.php | 64 +++++++++++++ resources/views/auth/register.blade.php | 91 +++++++++++++++++++ resources/views/auth/verify.blade.php | 24 +++++ resources/views/layouts/app.blade.php | 16 +++- routes/web.php | 5 +- 16 files changed, 521 insertions(+), 7 deletions(-) create mode 100644 app/Http/Controllers/Auth/ForgotPasswordController.php create mode 100644 app/Http/Controllers/Auth/RegisterController.php create mode 100644 app/Http/Controllers/Auth/ResetPasswordController.php create mode 100644 app/Http/Controllers/Auth/VerificationController.php create mode 100644 resources/views/auth/login.blade.php create mode 100644 resources/views/auth/passwords/email.blade.php create mode 100644 resources/views/auth/passwords/reset.blade.php create mode 100644 resources/views/auth/register.blade.php create mode 100644 resources/views/auth/verify.blade.php diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php new file mode 100644 index 0000000..6a247fe --- /dev/null +++ b/app/Http/Controllers/Auth/ForgotPasswordController.php @@ -0,0 +1,32 @@ +middleware('guest'); + } +} diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php new file mode 100644 index 0000000..757b5f7 --- /dev/null +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -0,0 +1,77 @@ +middleware('guest'); + } + + /** + * Get a validator for an incoming registration request. + * + * @param array $data + * @return \Illuminate\Contracts\Validation\Validator + */ + protected function validator(array $data) + { + return Validator::make($data, [ + 'name' => ['required', 'string', 'max:255'], + 'username' => ['required', 'string', 'max:255'], + 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], + 'password' => ['required', 'string', 'min:6'], + ]); + } + + /** + * Create a new user instance after a valid registration. + * + * @param array $data + * @return \App\User + */ + protected function create(array $data) + { + $user = new User([ + 'name' => $data['name'], + 'username' => $data['username'], + 'email' => $data['email'], + 'password' => bcrypt($data['password']), + ]); + $user->save(); + + return $user; + } +} diff --git a/app/Http/Controllers/Auth/ResetPasswordController.php b/app/Http/Controllers/Auth/ResetPasswordController.php new file mode 100644 index 0000000..cf726ee --- /dev/null +++ b/app/Http/Controllers/Auth/ResetPasswordController.php @@ -0,0 +1,39 @@ +middleware('guest'); + } +} diff --git a/app/Http/Controllers/Auth/VerificationController.php b/app/Http/Controllers/Auth/VerificationController.php new file mode 100644 index 0000000..23a43a8 --- /dev/null +++ b/app/Http/Controllers/Auth/VerificationController.php @@ -0,0 +1,41 @@ +middleware('auth'); + $this->middleware('signed')->only('verify'); + $this->middleware('throttle:6,1')->only('verify', 'resend'); + } +} diff --git a/app/Http/Controllers/LoginController.php b/app/Http/Controllers/LoginController.php index bf9cc85..2d8993a 100644 --- a/app/Http/Controllers/LoginController.php +++ b/app/Http/Controllers/LoginController.php @@ -42,12 +42,12 @@ public function handleProviderCallback() try { /** @var User $createdUser */ $createdUser = User::firstOrCreate([ - 'github_id' => $user->getId(), 'email' => $user->getEmail() ], [ 'name' => $user->getName(), 'email' => $user->getEmail(), 'username' => $user->getNickname(), + 'password' => bcrypt(substr(str_shuffle('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789') , 0 , 10 )), 'github_id' => $user->getId(), 'avatar' => $user->getAvatar(), ]); diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 35471f6..c8666d5 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -2,6 +2,7 @@ namespace App\Providers; +use Illuminate\Support\Facades\Schema; use Illuminate\Support\ServiceProvider; class AppServiceProvider extends ServiceProvider @@ -23,6 +24,6 @@ public function boot() */ public function register() { - // + Schema::defaultStringLength(191); } } diff --git a/app/User.php b/app/User.php index 35207d2..1ed0d05 100644 --- a/app/User.php +++ b/app/User.php @@ -22,6 +22,7 @@ class User extends Authenticatable 'email', 'username', 'github_id', + 'password', 'avatar', 'bio', 'airport_code', @@ -58,7 +59,8 @@ class User extends Authenticatable 'name' => 'required|string|max:255', 'email' => 'required|string|email|max:255|unique:users,email', 'username' => 'required|string|max:255|unique:users,username', - 'github_id' => 'required|numeric|unique:users,github_id', + 'password' => 'required|string|max:255', + 'github_id' => 'numeric|unique:users,github_id', 'avatar' => 'nullable|string', 'bio' => 'nullable|string', 'airport_code' => 'nullable|size:3', 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 370d5cf..a3bb504 100644 --- a/database/migrations/2014_10_12_000000_create_users_table.php +++ b/database/migrations/2014_10_12_000000_create_users_table.php @@ -18,7 +18,8 @@ public function up() $table->string('name'); $table->string('email')->unique(); $table->string('username')->unique(); - $table->string('github_id')->unique(); + $table->string('password'); + $table->string('github_id')->nullable(); //speaker details $table->string('avatar')->nullable(); diff --git a/public/css/app.css b/public/css/app.css index 0589493..0a37806 100644 --- a/public/css/app.css +++ b/public/css/app.css @@ -1,3 +1,12 @@ +.cardRow{ + border-radius:7px; + background-color:#fff; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; +} + @import url(https://fonts.googleapis.com/css?family=Raleway:300,400,600);.cancel-on-png, .cancel-off-png, .star-on-png, .star-off-png, .star-half-png { font-size: 2em; } diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php new file mode 100644 index 0000000..b991b0c --- /dev/null +++ b/resources/views/auth/login.blade.php @@ -0,0 +1,72 @@ +@extends('layouts.app') + +@section('content') +
+
+

{{ __('Login') }}

+
+
+
+
+ @csrf + +
+ + +
+ + + @if ($errors->has('email')) + + {{ $errors->first('email') }} + + @endif +
+
+ +
+ + +
+ + + @if ($errors->has('password')) + + {{ $errors->first('password') }} + + @endif +
+
+ +
+
+
+ + + +
+
+
+ +
+
+ + + @if (Route::has('password.request')) + + {{ __('Forgot Your Password?') }} + + @endif +
+
+
+
+
+
+
+
+@endsection diff --git a/resources/views/auth/passwords/email.blade.php b/resources/views/auth/passwords/email.blade.php new file mode 100644 index 0000000..99a6f02 --- /dev/null +++ b/resources/views/auth/passwords/email.blade.php @@ -0,0 +1,46 @@ +@extends('layouts.app') + +@section('content') +
+
+

{{ __('Reset Password') }}

+
+
+
+ @if (session('status')) + + @endif + +
+ @csrf + +
+ + +
+ + + @if ($errors->has('email')) + + {{ $errors->first('email') }} + + @endif +
+
+ +
+
+ +
+
+
+
+
+
+
+
+@endsection diff --git a/resources/views/auth/passwords/reset.blade.php b/resources/views/auth/passwords/reset.blade.php new file mode 100644 index 0000000..f8ef8e8 --- /dev/null +++ b/resources/views/auth/passwords/reset.blade.php @@ -0,0 +1,64 @@ +@extends('layouts.app') + +@section('content') +
+
+

{{ __('Reset Password') }}

+
+
+
+
+ @csrf + + + +
+ + +
+ + + @if ($errors->has('email')) + + {{ $errors->first('email') }} + + @endif +
+
+ +
+ + +
+ + + @if ($errors->has('password')) + + {{ $errors->first('password') }} + + @endif +
+
+ +
+ + +
+ +
+
+ +
+
+ +
+
+
+
+
+
+
+
+@endsection diff --git a/resources/views/auth/register.blade.php b/resources/views/auth/register.blade.php new file mode 100644 index 0000000..a20225f --- /dev/null +++ b/resources/views/auth/register.blade.php @@ -0,0 +1,91 @@ +@extends('layouts.app') + +@section('content') +
+
+

{{ __('Register') }}

+
+
+
+
+ @csrf + +
+ + +
+ + + @if ($errors->has('name')) + + {{ $errors->first('name') }} + + @endif +
+
+ +
+ + +
+ + + @if ($errors->has('email')) + + {{ $errors->first('email') }} + + @endif +
+
+ + +
+ + +
+ + + @if ($errors->has('username')) + + {{ $errors->first('username') }} + + @endif +
+
+ +
+ + +
+ + + @if ($errors->has('password')) + + {{ $errors->first('password') }} + + @endif +
+
+ +
+ + +
+ +
+
+ +
+
+ +
+
+
+
+
+
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/auth/verify.blade.php b/resources/views/auth/verify.blade.php new file mode 100644 index 0000000..c742cb4 --- /dev/null +++ b/resources/views/auth/verify.blade.php @@ -0,0 +1,24 @@ +@extends('layouts.app') + +@section('content') +
+
+
+
+
{{ __('Verify Your Email Address') }}
+ +
+ @if (session('resent')) + + @endif + + {{ __('Before proceeding, please check your email for a verification link.') }} + {{ __('If you did not receive the email') }}, {{ __('click here to request another') }}. +
+
+
+
+
+@endsection diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index 31c6b28..35204c9 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -98,9 +98,21 @@ class="fa fa-list"> My Talks