From 42598ddb3d0dd629406ebd7186159e3fc130b19c Mon Sep 17 00:00:00 2001 From: Yorhel Date: Fri, 2 Oct 2020 10:44:37 +0200 Subject: v2rw: Move redirects + cleanup some more --- lib/VNDB/Handler/Misc.pm | 12 ----------- lib/VNDB/Handler/VNPage.pm | 8 -------- lib/VNDB/Util/Auth.pm | 50 +--------------------------------------------- 3 files changed, 1 insertion(+), 69 deletions(-) (limited to 'lib/VNDB') diff --git a/lib/VNDB/Handler/Misc.pm b/lib/VNDB/Handler/Misc.pm index 565523e6..d2cb9c0d 100644 --- a/lib/VNDB/Handler/Misc.pm +++ b/lib/VNDB/Handler/Misc.pm @@ -13,18 +13,6 @@ TUWF::register( qr{nospam}, \&nospam, qr{xml/prefs\.xml}, \&prefs, qr{opensearch\.xml}, \&opensearch, - - # redirects for old URLs - qr{u([1-9]\d*)/tags}, sub { $_[0]->resRedirect("/g/links?u=$_[1]", 'perm') }, - qr{(.*[^/]+)/+}, sub { $_[0]->resRedirect("/$_[1]", 'perm') }, - qr{([pv])}, sub { $_[0]->resRedirect("/$_[1]/all", 'perm') }, - qr{v/search}, sub { $_[0]->resRedirect("/v/all?q=".uri_escape($_[0]->reqGet('q')||''), 'perm') }, - qr{notes}, sub { $_[0]->resRedirect('/d8', 'perm') }, - qr{faq}, sub { $_[0]->resRedirect('/d6', 'perm') }, - qr{v([1-9]\d*)/(?:stats|scr)}, - sub { $_[0]->resRedirect("/v$_[1]", 'perm') }, - qr{u/list(/[a-z0]|/all)?}, - sub { my $l = defined $_[1] ? $_[1] : '/all'; $_[0]->resRedirect("/u$l", 'perm') }, ); diff --git a/lib/VNDB/Handler/VNPage.pm b/lib/VNDB/Handler/VNPage.pm index 1198a421..b546c436 100644 --- a/lib/VNDB/Handler/VNPage.pm +++ b/lib/VNDB/Handler/VNPage.pm @@ -9,18 +9,10 @@ use VNDB::Types; TUWF::register( - qr{v/rand} => \&rand, qr{v([1-9]\d*)/releases} => \&releases, - qr{v([1-9]\d*)/staff} => sub { $_[0]->resRedirect("/v$_[1]#staff") }, ); -sub rand { - my $self = shift; - $self->resRedirect('/v'.$self->filFetchDB(vn => undef, undef, {results => 1, sort => 'rand'})->[0]{id}, 'temp'); -} - - # Description of each column, field: # id: Identifier used in URLs # sort_field: Name of the field when sorting diff --git a/lib/VNDB/Util/Auth.pm b/lib/VNDB/Util/Auth.pm index b05c86f9..f3094ff0 100644 --- a/lib/VNDB/Util/Auth.pm +++ b/lib/VNDB/Util/Auth.pm @@ -10,58 +10,10 @@ use VNWeb::Auth; our @EXPORT = qw| - authInit authLogin authLogout authInfo authCan authSetPass authAdminSetPass - authResetPass authIsValidToken authGetCode authCheckCode authPref + authInfo authCan authGetCode authCheckCode authPref |; -# login, arguments: user, password, url-to-redirect-to-on-success -# returns 1 on success (redirected), 0 otherwise (no reply sent) -sub authLogin { - my(undef, $user, $pass, $to) = @_; - my $success = auth->login($user, $pass); - tuwf->resRedirect($to, 'post') if $success; - $success -} - -# clears authentication cookie and redirects to / -sub authLogout { - auth->logout; - tuwf->resRedirect('/', 'temp'); -} - - -# Replaces the user's password with a random token that can be used to reset the password. -sub authResetPass { - my(undef, $mail) = @_; - auth->resetpass($mail) -} - - -sub authIsValidToken { - my(undef, $uid, $token) = @_; - auth->isvalidtoken($uid, $token) -} - - -# uid, new_pass, url_to_redir_to, 'token'|'pass', $token_or_pass -# Changes the user's password, invalidates all existing sessions, creates a new -# session and redirects. -sub authSetPass { - my(undef, $uid, $pass, $redir, $oldtype, $oldpass) = @_; - - my $success = auth->setpass($uid, $oldtype eq 'token' ? $oldpass : undef, $oldtype eq 'pass' ? $oldpass : undef, $pass); - tuwf->resRedirect($redir, 'post') if $success; - $success -} - - -sub authAdminSetPass { - my(undef, $uid, $pass) = @_; - auth->admin_setpass($uid, $pass); -} - - sub authInfo { # Used to return a lot more, but only the id is still used now. # (code using other fields has been migrated) -- cgit v1.2.3