You are here

function drd_server_connect in Drupal Remote Dashboard Server 7

Same name and namespace in other branches
  1. 6 drd_server.module \drd_server_connect()

Authenticate a user.

This function is used to authenticate a user with the associated password and if successful returns the session ID for future access.

Parameters

$username: The name of the user to be authenticated.

$password: The password of the user to be authenticated.

Return value

The session ID if the user got successfully authenticated, an error message otherwise.

1 string reference to 'drd_server_connect'
drd_server_xmlrpc in ./drd_server.module
Implementation of hook_xmlrpc().

File

./drd_server.module, line 62

Code

function drd_server_connect($username, $password) {
  $form_state['values']['name'] = $username;
  $form_state['values']['pass'] = $password;
  $form_state['values']['op'] = t('Login');
  $GLOBALS['drd_xmlrpc_mode'] = TRUE;
  drupal_form_submit('user_login', $form_state);
  if (!form_get_errors()) {
    if (user_access('administer site configuration')) {
      return drd_server_result('connect', session_id());
    }
    else {
      return drd_server_error(t('You do not have permission to access system data.'));
    }
  }
  else {
    return drd_server_error(t('Wrong username or password.'));
  }
}