You are here

function oauth_common_form_authorize_validate in OAuth 1.0 7.4

Same name and namespace in other branches
  1. 6.3 oauth_common.pages.inc \oauth_common_form_authorize_validate()
  2. 7.3 oauth_common.pages.inc \oauth_common_form_authorize_validate()

Validation of the form for granting access to the consumer

File

./oauth_common.pages.inc, line 234

Code

function oauth_common_form_authorize_validate($form, &$form_state) {
  $values = $form_state['values'];
  $got_permission = FALSE;
  $consumer = $values['token']->consumer;
  $context = oauth_common_context_load($consumer->context);
  if (!$context) {
    form_set_error('confirm', t("Can't find OAuth context."));
    return;
  }
  if (!$context->authorization_options['disable_auth_level_selection']) {
    foreach ($context->authorization_levels as $name => $level) {
      if ($values['levels'][$name]) {
        $got_permission = TRUE;
        break;
      }
    }
    if (!$got_permission) {
      form_set_error('confirm', t("You haven't given the application access to anything. Click on 'Deny access' or just close this window if you don't want to authorize it."));
    }
  }
}