'OAuth user Authentication
:userinfo: dict with user information the keys have the same name
as User model columns.'

def auth_user_oauth(self, userinfo):

    if ('username' in userinfo):
        user = self.find_user(username=userinfo['username'])
    elif ('email' in userinfo):
        user = self.find_user(email=userinfo['email'])
    else:
        log.error('User    info    does    not    have    username    or    email    {0}'.format(userinfo))
        return None
    if (user and (not user.is_active())):
        log.info(LOGMSG_WAR_SEC_LOGIN_FAILED.format(userinfo))
        return None
    if ((not user) and (not self.auth_user_registration)):
        return None
    if (not user):
        user = self.add_user(username=userinfo['username'], first_name=userinfo['first_name'], last_name=userinfo['last_name'], email=userinfo['email'], role=self.find_role(self.auth_user_registration_role))
        if (not user):
            log.error(('Error    creating    a    new    OAuth    user    %s' % userinfo['username']))
            return None
    self.update_user_auth_stat(user)
    return user
