Skip to content

Commit

Permalink
Merge pull request #41 from leifermendez/arturol
Browse files Browse the repository at this point in the history
Arturol
  • Loading branch information
leifermendez authored Jun 7, 2021
2 parents b865e0a + 0d7bc4e commit a3d46ea
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
22 changes: 19 additions & 3 deletions app/Http/Controllers/Auth/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,32 @@ function authenticated(Request $request)
$agent = new Agent();
$a = ($agent->isMobile() || $agent->isTablet()) ? 'Móvil' : 'Escritorio';
$geoIp = GeoIP::getLocation($request->ip());
$url = 'https://api.ipregistry.co/'.$geoIp['ip'].'?key=q49696zvy4aq1y';
// Initiate curl
$ch = curl_init();
// Will return the response, if false it print the response
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Set the url
curl_setopt($ch, CURLOPT_URL, $url);
// Execute
$result=curl_exec($ch);
// Closing
curl_close($ch);

$result = json_decode($result);

// Will dump a beauty json :3

$device = array(
'Dispositivo' => $a,
'Tipo' => $agent->device(),
'Ip' => $geoIp['ip'],
'plataforma' => $agent->platform(),
'Direccion' => $geoIp['city'],
'Mapa' => 'https://www.google.com/maps/search/?api=1&query='.$geoIp['lat'].','.$geoIp['lon'],
'Coordenadas' => $geoIp['lat'].','.$geoIp['lon'],
'Direccion' => $result->location->city,
'Mapa' => 'https://www.google.com/maps/search/?api=1&query='.$result->location->latitude.','.$result->location->longitude,
'Coordenadas' => $result->location->latitude.','.$result->location->longitude,
);

$user = User::find(Auth::id());
$audit = array(
'created_at' => Carbon::now(),
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Middleware/Device.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function handle($request, Closure $next)
$agent = new Agent();
$a = ($agent->isMobile() || $agent->isTablet()) ? 'Móvil' : 'Escritorio';
$geoIp = GeoIP::getLocation($request->ip());
$url = 'https://api.ipregistry.co/'.'186.90.111.220'.'?key=q49696zvy4aq1y';
$url = 'https://api.ipregistry.co/'.$geoIp['ip'].'?key=q49696zvy4aq1y';
// Initiate curl
$ch = curl_init();
// Will return the response, if false it print the response
Expand Down

0 comments on commit a3d46ea

Please sign in to comment.