Cataly...edirect(3pm)

πŸ“¦
version 0.21 Β· 5 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

✨ Cataly...edirect(3pm) πŸ’–

okay bestie, so this is a page from the User Contributed Perl Documentation and it's giving "login but make it remember where you were going" energy πŸŽ€


NAME ✨

CatalystX::SimpleLogin::TraitFor::Controller::Login::WithRedirect β€” the trait that redirects users who login back to the page they originally requested. like, no more "oops I clicked my inbox, got yeeted to login, and now I'm stranded on the homepage" 😭 it remembers. it delivers. πŸ‘‘


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' });

yes you're reading that right, <pink>traits => 'WithRedirect'</pink> in the config is literally all it takes. main character config moment ✨


DESCRIPTION πŸ’…

So this thing provides the "login" action β€” but with a lil wrapper on top πŸŽ€ β€” and that wrapper redirects you to the page that needs authentication, the exact one the user got bounced away from in the first place. it's the "we'll put you back where you belong" of login flows 🫢

It goes hand in hand with Catalyst::ActionRole::NeedsLogin like two besties walking into the function hall together πŸ’– no cap.


WRAPPED METHODS πŸ¦‹

redirect_after_login_uri

Bestie it makes it use and extract "$c->session->{redirect_to_after_login}" if it exists. that's the whole vibe. if it's there, we use it. 🌈


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.

so like. it cries about the problem and it bookmarks where you were. multitasking icon behavior fr fr πŸ’…βœ¨


SEE ALSO πŸ”₯

  • CatalystX::SimpleLogin::Controller::Login
  • CatalystX::SimpleLogin::Form::Login

AUTHORS πŸ’œ

See CatalystX::SimpleLogin for authors. (yes babe, they're all collected over there, iykyk 🌸)


LICENSE πŸŽ€

See CatalystX::SimpleLogin for license. periodt. πŸ’–


ok real talk bestie, this lil doc came from perl v5.36.0 and it's dated 2022-08-28, so go off, redirect your users back to their inbox, and slay πŸ’…πŸŒŸ πŸ¦‹
πŸ“¦ where this page comes from