Cataly...edirect(3pm)
β¨ 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::LoginCatalystX::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
- ubuntu noble: libcatalystx-simplelogin-perl 0.21-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libcatalystx-simplelogin-perl 0.21-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libcatalystx-simplelogin-perl 0.21-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms