use custom function to get client ip since Symfony's sucks
This commit is contained in:
parent
6d6abf41f5
commit
f7159e0bbb
@ -117,17 +117,16 @@ class AuthController extends Controller
|
||||
|
||||
// If amount of registered accounts of IP is more than allowed amounts,
|
||||
// then reject the register.
|
||||
if (User::where('ip', $request->ip())->count() < option('regs_per_ip'))
|
||||
if (User::where('ip', Utils::getClientIp())->count() < option('regs_per_ip'))
|
||||
{
|
||||
// Register a new user.
|
||||
// If the email is already registered,
|
||||
// it will return a false value.
|
||||
$user = User::register(
|
||||
$request->input('email'),
|
||||
$request->input('password'),
|
||||
function($user) use ($request)
|
||||
$request->input('password'), function($user) use ($request)
|
||||
{
|
||||
$user->ip = $request->ip();
|
||||
$user->ip = Utils::getClientIp();
|
||||
$user->score = option('user_initial_score');
|
||||
$user->register_at = Utils::getTimeFormatted();
|
||||
$user->last_sign_at = Utils::getTimeFormatted(time() - 86400);
|
||||
|
@ -111,10 +111,9 @@ class SetupController extends Controller
|
||||
// register super admin
|
||||
$user = User::register(
|
||||
$request->input('email'),
|
||||
$request->input('password'),
|
||||
function ($user) use ($request)
|
||||
$request->input('password'), function ($user)
|
||||
{
|
||||
$user->ip = $request->ip();
|
||||
$user->ip = Utils::getClientIp();
|
||||
$user->score = option('user_initial_score');
|
||||
$user->register_at = Utils::getTimeFormatted();
|
||||
$user->last_sign_at = Utils::getTimeFormatted(time() - 86400);
|
||||
|
@ -8,6 +8,24 @@ use App\Exceptions\PrettyPageException;
|
||||
|
||||
class Utils
|
||||
{
|
||||
/**
|
||||
* Returns the client IP address.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getClientIp()
|
||||
{
|
||||
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
|
||||
$ip = $_SERVER['HTTP_CLIENT_IP'];
|
||||
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
|
||||
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||
} else {
|
||||
$ip = $_SERVER['REMOTE_ADDR'];
|
||||
}
|
||||
|
||||
return $ip;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename uploaded file
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user