my guess is that we're assuming you already have this done, documenting for my benefit
if you haven't already
curl -sS https://getcomposer.org/installer | php
Or maybe update composer:
/usr/local/bin/composer self-update
composer global require "laravel/installer=~1.1"
- punting on this for now
laravel new two-factor-auth
Start MAMP for MySQL
Update database.php
with mysql settings
(Following copy is from PHP Client for Authy Github)
Include it in your composer.json
{
"require": {
"authy/php": "2.*"
}
}
This is from Authy and Laravel post mentioned below in resources:
php artisan make:migration create_users_table
Make it look like this:
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function(Blueprint $table)
{
$table->increments('id');
$table->string('email');
$table->string('username');
$table->string('password');
$table->string('authy')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('users');
}
}
To use this client you just need to use Authy_Api and initialize it with your API KEY
$authy_api = new Authy\AuthyApi('#your_api_key');
Creating users is very easy, you need to pass an email, a cellphone and optionally a country code:
$user = $authy_api->registerUser('[email protected]', '405-342-5699', 1); //email, cellphone, country_code
You can easily see if the user was created by calling ok(). If request went right, you need to store the authy id in your database. Use user->id() to get this id in your database.
if($user->ok())
// store user->id() in your user database
else
foreach($user->errors() as $field => $message) {
printf("$field = $message");
}
it returns a dictionary explaining what went wrong with the request. Errors will be in plain English and can be passed back to the user.
- Laracasts - What's new in 5.0?
- Laravel 5 docs
- This dude's post on Authy and Laravel
- Authy's PHP developer kit
Think we're just going hard after combinations of:
- Laravel
- Laravel 5.0
- Two factor auth
- 2FA
- TFA