Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auth #13

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
38 changes: 0 additions & 38 deletions .env.example

This file was deleted.

32 changes: 32 additions & 0 deletions app/Http/Controllers/Auth/ForgotPasswordController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;

class ForgotPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset emails and
| includes a trait which assists in sending these notifications from
| your application to your users. Feel free to explore this trait.
|
*/

use SendsPasswordResetEmails;

/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
}
77 changes: 77 additions & 0 deletions app/Http/Controllers/Auth/RegisterController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php

namespace App\Http\Controllers\Auth;

use App\User;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;

class RegisterController extends Controller
{
/*
|--------------------------------------------------------------------------
| Register Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users as well as their
| validation and creation. By default this controller uses a trait to
| provide this functionality without requiring any additional code.
|
*/

use RegistersUsers;

/**
* Where to redirect users after registration.
*
* @var string
*/
protected $redirectTo = '/home';

/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->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;
}
}
39 changes: 39 additions & 0 deletions app/Http/Controllers/Auth/ResetPasswordController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ResetsPasswords;

class ResetPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset requests
| and uses a simple trait to include this behavior. You're free to
| explore this trait and override any methods you wish to tweak.
|
*/

use ResetsPasswords;

/**
* Where to redirect users after resetting their password.
*
* @var string
*/
protected $redirectTo = '/home';

/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
}
41 changes: 41 additions & 0 deletions app/Http/Controllers/Auth/VerificationController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\VerifiesEmails;

class VerificationController extends Controller
{
/*
|--------------------------------------------------------------------------
| Email Verification Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling email verification for any
| user that recently registered with the application. Emails may also
| be re-sent if the user didn't receive the original email message.
|
*/

use VerifiesEmails;

/**
* Where to redirect users after verification.
*
* @var string
*/
protected $redirectTo = '/home';

/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
$this->middleware('signed')->only('verify');
$this->middleware('throttle:6,1')->only('verify', 'resend');
}
}
2 changes: 1 addition & 1 deletion app/Http/Controllers/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
]);
Expand Down
3 changes: 2 additions & 1 deletion app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Providers;

use Illuminate\Support\Facades\Schema;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
Expand All @@ -23,6 +24,6 @@ public function boot()
*/
public function register()
{
//
Schema::defaultStringLength(191);
}
}
4 changes: 3 additions & 1 deletion app/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class User extends Authenticatable
'email',
'username',
'github_id',
'password',
'avatar',
'bio',
'airport_code',
Expand Down Expand Up @@ -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',
Expand Down
3 changes: 2 additions & 1 deletion database/migrations/2014_10_12_000000_create_users_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bdemirpolat Burak migration'da herhangi bir değişiklik yapılacağı zaman yeni bir migration oluşturup yapman gerekiyor ki daha önce dotCFP'i kurmuş kişiler etkilenmesin. Örneğin cfp.phpkonf.org'da biz bu migration'ı çalıştırdık ve users tablosuna kayıtlar girildi. Ben yeniden bu migration'ı çalıştırmak için migrate:refresh gibi bir komut verirsem verileri kaybederim. Ama aşağıdaki gibi yeni bir migration oluşturup eklersen yeni eklediğin password alanını da kullanabiliyor olurum.

php artisan make:migration add_password_to_users_table

$table->string('github_id')->nullable();

//speaker details
$table->string('avatar')->nullable();
Expand Down
9 changes: 9 additions & 0 deletions public/css/app.css
Original file line number Diff line number Diff line change
@@ -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;
}
Expand Down
72 changes: 72 additions & 0 deletions resources/views/auth/login.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
@extends('layouts.app')

@section('content')
<div class="container">
<div class="row cardRow" >
<h2 class="text-center">{{ __('Login') }}</h2>
<div class="col-md-8 formDiv" >
<div class="card">
<div class="card-body">
<form method="POST" action="{{ route('login') }}">
@csrf

<div class="form-group row">
<label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>

<div class="col-md-6">
<input id="email" type="email" class="form-control{{ $errors->has('email') ? ' is-invalid' : '' }}" name="email" value="{{ old('email') }}" required autofocus>

@if ($errors->has('email'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('email') }}</strong>
</span>
@endif
</div>
</div>

<div class="form-group row">
<label for="password" class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label>

<div class="col-md-6">
<input id="password" type="password" class="form-control{{ $errors->has('password') ? ' is-invalid' : '' }}" name="password" required>

@if ($errors->has('password'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('password') }}</strong>
</span>
@endif
</div>
</div>

<div class="form-group row">
<div class="col-md-6 col-md-6 col-md-push-4">
<div class="form-check">
<input class="form-check-input" type="checkbox" name="remember" id="remember" {{ old('remember') ? 'checked' : '' }}>

<label class="form-check-label" for="remember">
{{ __('Remember Me') }}
</label>
</div>
</div>
</div>

<div class="form-group row mb-0">
<div class="col-md-8 col-md-6 col-md-push-4">
<button type="submit" class="btn btn-primary">
{{ __('Login') }}
</button>

@if (Route::has('password.request'))
<a class="btn btn-link" href="{{ route('password.request') }}">
{{ __('Forgot Your Password?') }}
</a>
@endif
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
@endsection
Loading