Skip to content

Commit

Permalink
changed format of login logs - fixes SAFeSEA#15
Browse files Browse the repository at this point in the history
  • Loading branch information
vanch3d committed Sep 27, 2013
1 parent ee2af3e commit d78a5ee
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions app/controllers/login.controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,26 @@ public function index()
if ($this->auth->login($this->post('username'), $this->post('password'))) {
//$this->app->flash('info', 'Your login was successful');

$user=$this->auth->getUser();
$user= $this->auth->getUser();
$req = $this->app->request();

$useragent = $this->app->request()->headers('USER_AGENT');
if ($useragent)
{
$log = $this->app->getLog();
$log->info(TutorController::ACTION_LOGIN . " | " .
json_encode(array('user_agent'=> $useragent)));
}
$useragent = $req->headers('USER_AGENT') ?: "";

$tmpl = '%action% | [%user% @ %IP%] | %message%';
$message = str_replace(array(
'%action%',
'%user%',
'%IP%',
'%message%'
), array(
TutorController::ACTION_LOGIN,
$user['username']?:"anon",
$req->getIp(),
json_encode(array('user_agent'=> $useragent))
), $tmpl);

$log = $this->app->getLog();
$log->info($message);
$this->redirect('me.home');
}
else
Expand Down

0 comments on commit d78a5ee

Please sign in to comment.