drupalchat.mobileauth.inc in DrupalChat 7.2
File
drupalchat.mobileauth.inc
View source
<?php
function drupalchat_mobile_auth() {
if (variable_get('drupalchat_enable_mobile_sdk_integration', '2') == '1') {
$form_state = array(
'values' => array(
'name' => $_POST['username'],
'pass' => $_POST['password'],
'submit' => 'Log in',
'form_build_id' => 'form-' . drupal_random_key(),
'form_id' => 'user_login_block',
'op' => 'Log in',
),
);
user_login_authenticate_validate(null, $form_state);
if (empty($form_state['uid'])) {
flood_register_event('failed_login_attempt_ip', variable_get('user_failed_login_ip_window', 3600));
if (isset($form_state['flood_control_user_identifier'])) {
flood_register_event('failed_login_attempt_user', variable_get('user_failed_login_user_window', 21600), $form_state['flood_control_user_identifier']);
}
if (isset($form_state['flood_control_triggered'])) {
if ($form_state['flood_control_triggered'] == 'user') {
print_r('Temporarily blocked.');
}
else {
print_r('IP blocked');
}
}
else {
print_r('Wrong password');
}
}
elseif (isset($form_state['flood_control_user_identifier'])) {
flood_clear_event('failed_login_attempt_user', $form_state['flood_control_user_identifier']);
global $user;
$user = user_load($form_state['uid']);
$result = _drupalchat_get_auth($_POST['username']);
drupal_json_output($result);
}
else {
drupal_access_denied();
}
}
else {
print_r("Please Enable Mobile SDK Integration");
}
}