public function logInAsAction()
{
if (!ctype_digit($_POST['id'])) {
$this->flasher->error('User ID is invalid - not a number: ' . $_POST['id']);
$this->redirect('/users');
}
$logInAs = Gatekeeper::findUserById($_POST['id']);
if ($logInAs && !$logInAs->inGroup('admin')) {
$_SESSION['superuser'] = $this->user->username;
$_SESSION['user'] = $logInAs->username;
$this->flasher->success('Successfully logged in as ' . $logInAs->username);
} else {
$this->flasher->error('Cannot log in as user with ID ' . $_POST['id']);
}
$this->redirect('/');
}