Review and port SSO functionality

issue on drupal.org : https://www.drupal.org/node/2299397
empty()