Skip to content

Commit

Permalink
update readme and replace environment check with .env settings to ena…
Browse files Browse the repository at this point in the history
…ble/disable recaptcha
  • Loading branch information
jeremykenedy committed May 27, 2017
1 parent 86cc182 commit 301f338
Show file tree
Hide file tree
Showing 6 changed files with 175 additions and 169 deletions.
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ NULL_IP_ADDRESS=0.0.0.0
DEBUG_BAR_ENVIRONMENT=local

USER_RESTORE_CUTOFF_DAYS=31
USER_RESTORE_ENRYPTION_KEY=
USER_RESTORE_ENCRYPTION_KEY=

DEFAULT_GRAVATAR_SIZE=80
DEFAULT_GRAVATAR_FALLBACK=http://c1940652.r52.cf0.rackcdn.com/51ce28d0fb4f442061000000/Screen-Shot-2013-06-28-at-5.22.23-PM.png
Expand All @@ -62,6 +62,7 @@ GOOGLE_SECRET=YOURGOOGLEPLUSsecretHERE
GOOGLE_REDIRECT=http://yourwebsiteURLhere.com/social/handle/google

# https://www.google.com/recaptcha/admin#list
ENABLE_RECAPTCHA=true
RE_CAP_SITE=YOURGOOGLECAPTCHAsitekeyHERE
RE_CAP_SECRET=YOURGOOGLECAPTCHAsecretHERE

Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Thumbs.db
### PHPSTORM BOOGERS ###
.idea/*
/.idea/*
.phpintel/*
/.phpintel/*

### DIFFERENT TYPE OF MASTER CONFIGS ###
.env
Expand Down
34 changes: 18 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ NULL_IP_ADDRESS=0.0.0.0
DEBUG_BAR_ENVIRONMENT=local

USER_RESTORE_CUTOFF_DAYS=31
USER_RESTORE_ENRYPTION_KEY=
USER_RESTORE_ENCRYPTION_KEY=

DEFAULT_GRAVATAR_SIZE=80
DEFAULT_GRAVATAR_FALLBACK=http://c1940652.r52.cf0.rackcdn.com/51ce28d0fb4f442061000000/Screen-Shot-2013-06-28-at-5.22.23-PM.png
Expand All @@ -304,6 +304,7 @@ GOOGLE_SECRET=YOURGOOGLEPLUSsecretHERE
GOOGLE_REDIRECT=http://yourwebsiteURLhere.com/social/handle/google

# https://www.google.com/recaptcha/admin#list
ENABLE_RECAPTCHA=false
RE_CAP_SITE=YOURGOOGLECAPTCHAsitekeyHERE
RE_CAP_SECRET=YOURGOOGLECAPTCHAsecretHERE

Expand Down Expand Up @@ -594,7 +595,7 @@ Code and documentation copyright 2011-2017 the [Bootstrap Authors](https://githu
#### VAGRANT Dev Environment References
###### VAGRANT Virtual Machine Details
|Item |Value:
|Item |Value: |
|:------------- |:-------------|
|Hostname|homestead|
|IP Address|192.168.10.10|
Expand All @@ -604,58 +605,59 @@ Code and documentation copyright 2011-2017 the [Bootstrap Authors](https://githu
|Database Port|33060|
|Database Username|homestead|
|Database Password|secret|
###### Start VAGRANT
|Command |Action
|Command |Action |
|:------------- |:-------------|
| `vagrant up` | Start Vagrant VM |
| `vagrant up --provision` | Start Vagrant VM if vagrantfile updated |
| `vagrant halt` | Stop Vagrant VM |
###### Access VAGRANT SSH and MySQL
|Command |Action |
|Command |Action | |
|------------- |:------------- |:-------------|
| ```sudo ssh vagrant@127.0.0.1 -p 222``` | Access Vagrant VM via SSH. Password is ``` vagrant ``` |
| ```mysql -u homestead -psecret``` | Access Vagrant VM MySQL. Password is ``` vagrant ``` |
If you do not have Bower, it can be installed using Node Package Manager (NPM).
If you do not have NPM, it can be installed using NODE JS.
###Install NODE JS
####Node JS can be installed muliple ways:
### Install NODE JS
#### Node JS can be installed muliple ways:
Mac GUI Installer, easiest way (Simply [Download](https://nodejs.org/en/) and Install)
####Node JS can also be installed using Homebrew Package Manager with the following command:
#### Node JS can also be installed using Homebrew Package Manager with the following command:
```
brew install node
```
###Install Node Package Manager (NPM)
####NPM can be installed using the following command:
### Install Node Package Manager (NPM)
#### NPM can be installed using the following command:
```
npm install -g bower
```
###Install Bower
####Bower can be installed with the following command:
### Install Bower
#### Bower can be installed with the following command:
```
sudo npm install -g bower
```
###Install GULP
####GULP can be installed using the following command:
### Install GULP
#### GULP can be installed using the following command:
```
npm install -g gulp
```
###Install COMPOSER
### Install COMPOSER
####COMPOSER can be installed using the following commands:
#### COMPOSER can be installed using the following commands:
```
sudo curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
```
####COMPOSER on MAC OS X can be installed using the following commands:
#### COMPOSER on MAC OS X can be installed using the following commands:
```
sudo brew update
sudo brew tap homebrew/dupes
Expand Down
220 changes: 108 additions & 112 deletions app/Http/Controllers/Auth/RegisterController.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -3,122 +3,118 @@
namespace App\Http\Controllers\Auth;

use App;
use App\Http\Controllers\Controller;
use App\Models\User;
use App\Traits\ActivationTrait;
use App\Traits\CaptchaTrait;
use App\Traits\CaptureIpTrait;
use App\Traits\ActivationTrait;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;
use jeremykenedy\LaravelRoles\Models\Permission;
use Illuminate\Support\Facades\Validator;

use jeremykenedy\LaravelRoles\Models\Role;

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 ActivationTrait;
use CaptchaTrait;
use RegistersUsers;

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

/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest', [
'except' => 'logout'
]);
}

/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data)
{

$data['captcha'] = $this->captchaCheck();

if (App::environment('local')) {
$data['captcha'] = true;
}

return Validator::make($data,
[
'name' => 'required|max:255|unique:users',
'first_name' => '',
'last_name' => '',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|min:6|max:20|confirmed',
'password_confirmation' => 'required|same:password',
'g-recaptcha-response' => '',
'captcha' => 'required|min:1'
],
[
'name.unique' => trans('auth.userNameTaken'),
'name.required' => trans('auth.userNameRequired'),
'first_name.required' => trans('auth.fNameRequired'),
'last_name.required' => trans('auth.lNameRequired'),
'email.required' => trans('auth.emailRequired'),
'email.email' => trans('auth.emailInvalid'),
'password.required' => trans('auth.passwordRequired'),
'password.min' => trans('auth.PasswordMin'),
'password.max' => trans('auth.PasswordMax'),
'g-recaptcha-response.required' => trans('auth.captchaRequire'),
'captcha.min' => trans('auth.CaptchaWrong')
]
);

}

/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return User
*/
protected function create(array $data)
{

$ipAddress = new CaptureIpTrait;
$role = Role::where('name', '=', 'Unverified')->first();

$user = User::create([
'name' => $data['name'],
'first_name' => $data['first_name'],
'last_name' => $data['last_name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
'token' => str_random(64),
'signup_ip_address' => $ipAddress->getClientIp(),
'activated' => !config('settings.activation')
]);

$user->attachRole($role);
$this->initiateEmailActivation($user);

return $user;

}
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 ActivationTrait;
use CaptchaTrait;
use RegistersUsers;

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

/**
* Create a new controller instance.
*
* @return void
*/
public function __construct() {
$this->middleware('guest', [
'except' => 'logout'
]);
}

/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data) {

$data['captcha'] = $this->captchaCheck();

if (!config('settings.reCaptchStatus')) {
$data['captcha'] = true;
}

return Validator::make($data,
[
'name' => 'required|max:255|unique:users',
'first_name' => '',
'last_name' => '',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|min:6|max:20|confirmed',
'password_confirmation' => 'required|same:password',
'g-recaptcha-response' => '',
'captcha' => 'required|min:1'
],
[
'name.unique' => trans('auth.userNameTaken'),
'name.required' => trans('auth.userNameRequired'),
'first_name.required' => trans('auth.fNameRequired'),
'last_name.required' => trans('auth.lNameRequired'),
'email.required' => trans('auth.emailRequired'),
'email.email' => trans('auth.emailInvalid'),
'password.required' => trans('auth.passwordRequired'),
'password.min' => trans('auth.PasswordMin'),
'password.max' => trans('auth.PasswordMax'),
'g-recaptcha-response.required' => trans('auth.captchaRequire'),
'captcha.min' => trans('auth.CaptchaWrong')
]
);

}

/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return User
*/
protected function create(array $data) {

$ipAddress = new CaptureIpTrait;
$role = Role::where('name', '=', 'Unverified')->first();

$user = User::create([
'name' => $data['name'],
'first_name' => $data['first_name'],
'last_name' => $data['last_name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
'token' => str_random(64),
'signup_ip_address' => $ipAddress->getClientIp(),
'activated' => !config('settings.activation')
]);

$user->attachRole($role);
$this->initiateEmailActivation($user);

return $user;

}
}
Loading

0 comments on commit 301f338

Please sign in to comment.