Permalink
Browse files

Added ability to disable IpAuth for each user

  • Loading branch information...
jaimehgb committed May 16, 2018
1 parent fbbcca5 commit 50d6453a21aa21c323207f4bf8c072c04a048b83
@@ -171,18 +171,21 @@ public function login(Request $request)
}
}
if(!AuthorizedIp::isAuthorized($request->ip(), $wallet->id))
if($wallet->ipauth_enabled)
{
// send authorization mail
$attempt = AuthorizedIp::create($request, $wallet->id);
if (!$attempt)
return $this->error('Unexpected error. Please try again and if this issue persists contact us.');
Mail::to($wallet->email)->send(new AuthorizeIpMail($attempt));
return $this->error('We\'ve sent you an email to authorize the IP address trying to log in. If you have not received it check your spam folder.');
}
if(!AuthorizedIp::isAuthorized($request->ip(), $wallet->id))
{
// send authorization mail
$attempt = AuthorizedIp::create($request, $wallet->id);
if (!$attempt)
return $this->error('Unexpected error. Please try again and if this issue persists contact us.');
Mail::to($wallet->email)->send(new AuthorizeIpMail($attempt));
return $this->error('We\'ve sent you an email to authorize the IP address trying to log in. If you have not received it check your spam folder.');
}
// update authorized ip expiration time
AuthorizedIp::updateExpiration($request->ip(), $wallet->id);
// update authorized ip expiration time
AuthorizedIp::updateExpiration($request->ip(), $wallet->id);
}
if(!$wallet->login_key_enabled)
{
@@ -0,0 +1,32 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddIpauthEnabledColumnToWalletsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('wallets', function (Blueprint $table) {
$table->boolean('ipauth_enabled')->default(true);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('wallets', function (Blueprint $table) {
$table->dropColumn('ipauth_enabled');
});
}
}

0 comments on commit 50d6453

Please sign in to comment.