Google Login

I’ve been asked to add extra security to our site. We’re using Google to login people in and currently this is the security we have:

$googleService = $serviceFactory->createService('google', $credentials, $storage, array('userinfo_email', 'userinfo_profile'));

$app->get('/login', function () use ($app, $googleService) {
  if($app['session']->get('userinfo')) {
    return new RedirectResponse('/');
  return $app['twig']->render('login.twig', array(
    'login_url' => $googleService->getAuthorizationUri()->__toString(),
    'user'      => $app['session']->get('userinfo'),


$app->match('/auth/callback', function (Request $request) use ($app, $googleService) {
    // This was a callback request from google, get the token

    // Send a request with it
    $user = json_decode($googleService->request(''), true);

    if (substr($user['email'],-11)==='' || $user['email']==='') {
      $user['logged_in_date'] = date('Y-m-d');
      $app['session']->set('userinfo', $user);

      $log = new \\UserLoggedinLog();

    } else {
      $message = \\Swift_Message::newInstance()
      ->setSubject('Mycroft :: unauthorized login')
      ->setFrom(array('' => 'robot'))
      ->setBody(sprintf("The following email [%s] tried to login from IP [%s]", $user['email'], $request->getClientIp()));

    return $app->redirect('/');

Is there a way to set the email addresses/users that can log in? So if a member of staff leaves they can be prevent from logging in immediately?

It doesn’t matter if this is done through Google’s control panel, if anything that would be better.

I’ve built a database table with all of the ‘allowed’ users in it but I didn’t know if there was a way of getting Google login to check that and then only allow somebody if they’re in the database?

I’m not clear what you’re wanting to do.

but also limit it to only those in your database.

i.e. kind of a “double authentication”?

Yep that’s exactly what I want but don’t know how to do it.