You are here

public function LoginShadowboxController::password in Shadowbox 8

Displays user profile if user is logged in, or reset password shadowbox form for anonymous users.

1 string reference to 'LoginShadowboxController::password'
login_shadowbox.routing.yml in login_shadowbox/login_shadowbox.routing.yml
login_shadowbox/login_shadowbox.routing.yml

File

login_shadowbox/lib/Drupal/login_shadowbox/Controller/LoginShadowboxController.php, line 159
Contains \Drupal\login_shadowbox\Controller\LoginShadowboxController.

Class

LoginShadowboxController
Controller routines for login_shadowbox routes.

Namespace

Drupal\login_shadowbox\Controller

Code

public function password() {
  $user = $this
    ->currentUser();
  if ($user
    ->id()) {
    $response = $this
      ->redirect('user.view', array(
      'user' => $user
        ->id(),
    ));
  }
  else {
    $path = drupal_get_path('module', 'login_shadowbox');
    $css_path = $this
      ->config('login_shadowbox.settings')
      ->get('login_shadowbox_css');

    // Reset password form begin.
    $password_form = '<div id="shadowbox_password" class="shadowbox_login_wrapper">';
    $password_form .= '<button class="shadowbox_login_close_button">x</button>';
    $form_builder = $this
      ->formBuilder();
    $form = $form_builder
      ->getForm('Drupal\\user\\Form\\UserPasswordForm');
    $form['#attached'] = array(
      'css' => array(
        $css_path,
        array(
          'group' => 'CSS_DEFAULT',
        ),
      ),
      'js' => array(
        $path . '/scripts/login_shadowbox_messages.js',
      ),
    );
    $password_form .= drupal_render($form);
    $password_form .= '</div>';
    $password_form = array(
      '#theme' => 'login_shadowbox_page',
      '#title' => t('Request new password'),
      '#content' => $password_form,
      '#css' => drupal_get_css(),
      '#js' => drupal_get_js(),
    );
    exit(drupal_render($password_form));
  }
  return NULL;
}