/*
Check if logged into Google account
173939
public function checkAuth()
    {
        $response = $this->guzzleClient->get('https://accounts.google.com',
            ['cookies' => $this->cookieJar]
        );

        if (strpos($response->getEffectiveUrl(), 'ServiceLogin') !== false) {
            return false;
        }

        return true;
    }
208762
private void isUserLoggedIn() {
        String accountListCmd = azureCli.getLoggedInAccountList();
        Pair<Integer, InputStream> result = executeCommand(accountListCmd);
        if (result.getKey() == 0) {
            try {
                String accountList = IOUtils.toString(result.getValue(), StandardCharsets.UTF_8.name());

                JSONArray jsonArray = new JSONArray(accountList);
                for (int i = 0; i < jsonArray.length(); i++) {
                    JSONObject jsonObject = jsonArray.getJSONObject(i);
                    String loggedInUserName = jsonObject.getJSONObject("user").getString("name");
                    if (loggedInUserName.equalsIgnoreCase(config.getAzureUserName())) {
                        loggedInToAzure = true;
                        break;
                    }
                }
            } catch (IOException e) {
                logger.warn("Failed to parse command {} result. Exception: {}", accountListCmd, e.getMessage());
                logger.debug("Failed to parse command {} result. Exception: {}", accountListCmd, e.getStackTrace());
            }
        } else {
            logger.warn("Failed to get Azure logged in account list, command: {}.", accountListCmd);
        }
    }
212499
function checkRequired(opts, queryObject, updatedObject){
  if((queryObject &&!queryObject.options) && !updatedObject){
    return;
  }
  const { __user: user, __reason: reason } = queryObject && queryObject.options || updatedObject;
  if (opts.required && (opts.required.includes("user") && !user ||
      opts.required.includes("reason") && !reason)
  ){
    return true;
  }
}
601008
function(credentials){
      var socialLogin = false;
      if (credentials == undefined){
        credentials = {
          userid: $('#login_email').val(),
          password: $('#login_password').val()
        };
      } else if (typeof credentials === 'string'){
        socialLogin = true;
      }

      // Alter the UI to indicate that the login request is pending
      $('#login_button').attr('value', 'Logging in...');
      $('#register_button, #or').hide();

      var login = socialLogin ? cm.loginSocial.bind(cm) : cm.login.bind(cm);

      function loginError(msg){
        $('#login_button').attr('value', 'Login');
        $('#register_button, #or').show();
        todo.error('login', msg);
      }

      // Run CloudMine login request.
      login(credentials)
        .on('success', function(data){
          var services = data.profile.__services__;
          if(services){
            console.log("linked services:", services);
            data.profile.__services__.forEach(function(service){
              $('a.auth.' + service).hide();
            });
          }
          todo.process_login(data);
        })
        .on('unauthorized', function(data){
          loginError(data.errors[0]);
        })
        .on('error', function(data){
          loginError(data.errors ? data.errors[0] : "Error Logging in");
        })
    }
72053
public function checkIsLogin()
    {
        if (!$this->di->get("session")->has("user")) {
            $views = [
                ["comment/user/fail/fail", [], "main"]
            ];
            $this->di->get("pageRenderComment")->renderPage([
                "views" => $views,
                "title" => "Not logged in"
            ]);
        }
    }
490462
def _logged_in_successful(data):
        
        if re.match(r'^:(testserver\.local|tmi\.twitch\.tv)'
                    r' NOTICE \* :'
                    r'(Login unsuccessful|Error logging in)*$',
                    data.strip()):
            return False
        else:
            return True
1267492
function() {
        if (!self.initialized_) {
          self.initialized_ = true;
          // Listen to Auth events on iframe.
          self.oauthSignInHandler_.addAuthEventListener(self.authEventHandler_);
        }
      }
459799
function handleLogin(onCloudLoginSuccess) {
  const link = authLink();
  const authWindow = window.open(link, '_blank', 'width=1024,height=716');
  const handleToken = e => {
    // TODO: add security step to validate which domain the message is coming from
    authWindow.close();
    window.removeEventListener('message', handleToken);
    dropbox.setAccessToken(e.data.token);
    if (window.localStorage) {
      window.localStorage.setItem('dropbox', JSON.stringify({
        // dropbox token doesn't expire unless revoked by the user
        token: e.data.token,
        timetamp: new Date()
      }));
    }
    onCloudLoginSuccess();
  };
  window.addEventListener('message', handleToken);
}
714458
@CheckReturnValue(when = When.NEVER)
  public boolean isLoggedIn() {
    authLock.readLock().lock();
    try {
      return activeUser != null && activeUser.isLoggedIn();
    } finally {
      authLock.readLock().unlock();
    }
  }
731244
async function signupUser(form) {
  await client.connect();
  try {
    await api.signup(
      {
        credentials: {
          login: form.login.value,
          password: form.password.value
        },
        profile: {
          email: form.email.value
        }
      },
      'user'
    );
    displayMessage(
      'Account created',
      'Your account has been created, please check your emails to confirm your account',
      'is-success'
    );
    goTo('login');
  } catch (e) {
    displayMessage('Account not created', `Your account could not been created. Cause: ${e.message}`, 'is-danger');
  }
}
443724
function() {
      // UI initialized, it is OK to cancel last operation.
      self.initialized_ = true;
      // retrieve is only called if auto sign-in is enabled. Otherwise, it will
      // get skipped.
      var retrieveCredential = Promise.resolve(null);
      if (!autoSignInDisabled) {
        retrieveCredential =
            self.googleyolo_.retrieve(
                /** @type {!SmartLockRequestOptions} */ (config))
                .catch(function(error) {
                  // For user cancellation or concurrent request pass down.
                  // Otherwise suppress and run hint.
                  if (error.type ===
                      firebaseui.auth.GoogleYolo.Error.USER_CANCELED ||
                      error.type ===
                      firebaseui.auth.GoogleYolo.Error.CONCURRENT_REQUEST) {
                    throw error;
                  }
                  // Ignore all other errors to give hint a chance to run next.
                  return null;
                });
      }
      // Check if a credential is already available (previously signed in with).
      return retrieveCredential
          .then(function(credential) {
            if (!credential) {
              // Auto sign-in not complete.
              // Show account selector.
              return self.googleyolo_.hint(
                  /** @type {!SmartLockHintOptions} */ (config));
            }
            // Credential already available from the retrieve call. Pass it
            // through.
            return credential;
          })
          .catch(function(error) {
            // When user cancels the flow, reset the lastCancel promise and
            // resolve with false.
            if (error.type === firebaseui.auth.GoogleYolo.Error.USER_CANCELED) {
              self.lastCancel_ = Promise.resolve();
            } else if (error.type ===
                       firebaseui.auth.GoogleYolo.Error.CONCURRENT_REQUEST) {
              // Only one UI can be rendered at a time, cancel existing UI
              // and try again.
              self.cancel();
              return self.show(config, autoSignInDisabled);
            }
            // Return null as no credential is available.
            return null;
          });
    }
790299
function getUserInfo(auth) {
    return new Promise((resolve, reject) => {
        const oauth2 = google.oauth2({
            auth,
            version: 'v2',
        });

        oauth2.userinfo.v2.me.get((err, res) => {
            if (err) {
                reject(err);
            } else {
                resolve(res.data);
            }
            return;
        });
    });
}
12564
def check_auth(self):
        """"""
        if not self.logged_in:
            if self.relogin_interval and self.last_login and (time() - self.last_login) > self.relogin_interval:
                self.log(WARNING, 'Zabbix API not logged in. Performing Zabbix API relogin after %d seconds',
                         self.relogin_interval)
                self.relogin()  # Will raise exception in case of login error
            else:
                raise ZabbixAPIException('Not logged in.')
691298
function onFetchSignInMethodsForEmail() {
  var email = $('#fetch-sign-in-methods-email').val();
  auth.fetchSignInMethodsForEmail(email).then(function(signInMethods) {
    log('Sign in methods for ' + email + ' :');
    log(signInMethods);
    if (signInMethods.length == 0) {
      alertSuccess('Sign In Methods for ' + email + ': N/A');
    } else {
      alertSuccess(
          'Sign In Methods for ' + email +': ' + signInMethods.join(', '));
    }
  }, onAuthError);
}
33087
function isLogin()
    {
        if (isset($_SESSION[self::$session_prefix . 'isLogin']) and $_SESSION[self::$session_prefix . 'isLogin'] == 1)
        {
            return true;
        }
        return false;
    }
828622
function onSignInWithEmailAndPassword() {
  var email = $('#signin-email').val();
  var password = $('#signin-password').val();
  auth.signInWithEmailAndPassword(email, password)
      .then(onAuthUserCredentialSuccess, onAuthError);
}
789511
function (account, data, conn) {

	//if (l_logins.hasOwnProperty(account) === true)
		//return false;
	
	// check if user's unique data exists
	if (typeof data.data !== 'object') {
		LOG.error('data field does not exist, cannot add login data');
		return false;
	}
	
	LOG.warn('account: ' + account + ' data:', 'addLogin');
	LOG.warn(data);
	
	// attach login name to connection
	// NOTE: we attach connection object to the data stored in memory (not clean?)
	if (conn) {
		// NOTE: we use session because this request could come from an HTTP request
		// that does not have a persistent connectino record in SR.Conn
		SR.Conn.setSessionName(conn, account);
		data._conn = conn;
	}
	
	l_logins[account] = data;
	LOG.warn('user [' + account + '] login success, total count: ' + Object.keys(l_logins).length, 'user');

	delete data._conn;
	//console.log(data);
	
	// error check: make sure lastStatus field exists
	if (data.hasOwnProperty('lastStatus') === false || data.lastStatus === null) 
		data.lastStatus = {loginCount: 0};
	
	data.lastStatus.loginIP = conn.host;
	data.lastStatus.loginCount = data.lastStatus.loginCount + 1;
	data.lastStatus.time = conn.time;

	SR.DB.updateData(SR.Settings.DB_NAME_ACCOUNT, {account: account}, data,
					 	function () {
					 	},
					 	function () {
					 	});	

	return true;
}