---
name: "CatalystX::SimpleLogin::TraitFor::Controller::Login::WithRedirect"
section: "3pm"
platform: "linux"
package: "libcatalystx-simplelogin-perl"
version: "0.21-2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/CatalystX::SimpleLogin::TraitFor::Controller::Login::WithRedirect"
---

# CatalystX::SimpleLogin::TraitFor::Controller::Login::WithRedirect(3pm)

redirect users who login back to the page they originally requested.

## NAME

CatalystX::SimpleLogin::TraitFor::Controller::Login::WithRedirect - redirect users who login back to the page they originally requested.

## SYNOPSIS

```
    package MyApp::Controller::NeedsAuth;
    use Moose;
    use namespace::autoclean;
    # One needs to inherit from Catalyst::Controller in order
    # to get the Does('NeedsLogin') functionality.
    BEGIN { extends 'Catalyst::Controller'; }
    sub inbox : Path Does('NeedsLogin') {
        # Redirects to /login if not logged in
        my ($self, $c) = @_;
        $c->stash->{template} = "inbox.tt2";
        return;
    }
    # Turn on in config
    MyApp->config('Contoller::Login' => { traits => 'WithRedirect' });
```

## DESCRIPTION

Provides the `"login"` action with a wrapper to redirect to a page which needs authentication, from which the user was previously redirected. Goes hand in hand with Catalyst::ActionRole::NeedsLogin

## WRAPPED METHODS

### redirect\_after\_login\_uri

Make it use and extract `"$c->session->{redirect_to_after_login}"` if it exists.

## METHODS

### $controller-\>login\_redirect($c, $message)

This sets the error message to `$message` and sets `"$c->session->{redirect_to_after_login}"` to the current URL.

## SEE ALSO

- CatalystX::SimpleLogin::Controller::Login

  - CatalystX::SimpleLogin::Form::Login

  ## AUTHORS

See CatalystX::SimpleLogin for authors.

## LICENSE

See CatalystX::SimpleLogin for license.
