You are here

function _openid_connect_user_pass_form_validate in OpenID Connect / OAuth client 7

Same name and namespace in other branches
  1. 8 openid_connect.module \_openid_connect_user_pass_form_validate()
  2. 2.x openid_connect.module \_openid_connect_user_pass_form_validate()

Custom validation for the password reset form.

1 string reference to '_openid_connect_user_pass_form_validate'
openid_connect_form_user_pass_alter in ./openid_connect.module
Implements hook_form_FORM_ID_alter().

File

./openid_connect.module, line 932
A pluggable client implementation for the OpenID Connect protocol.

Code

function _openid_connect_user_pass_form_validate(array &$form, &$form_state) {

  // If the account doesn't exist, return early.
  if (empty($form_state['values']['account'])) {
    return;
  }
  $account = $form_state['values']['account'];
  $results = openid_connect_get_connected_accounts($account);

  // If not in the authmap table, return early.
  if (empty($results)) {
    return;
  }

  // If the user has permission to manage their local password, allow it.
  if (user_access('openid_connect set own password', $account)) {
    return;
  }
  form_set_error('name', t('%name is connected to an external authentication system.', array(
    '%name' => $form_state['values']['name'],
  )));
}