summaryrefslogtreecommitdiff
path: root/lib/VNDB/Handler
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2019-09-18 12:38:18 +0200
committerYorhel <git@yorhel.nl>2019-09-18 12:40:20 +0200
commit98c9d95e9b7a1e78f5cda93904c6624d57df4518 (patch)
treec54c17740bd0874a996d520323ebe2e7ed7ef029 /lib/VNDB/Handler
parentcc2a1d72e499f7befe1b615a1322952dfb628fab (diff)
v2rw: Convert authentication code to VNWeb::Auth
More churn! Also converted v3 to use VNWeb::Auth, considering the API is pretty much the same. Converted VNWeb::* to use VNDB::Config directly rather than read from tuwf->{}, converted VNWeb::HTML to use VNWeb::Auth, and updated util/vndb.pl with the new code style. I tested as much as I could, but I'm sure I broke something.
Diffstat (limited to 'lib/VNDB/Handler')
-rw-r--r--lib/VNDB/Handler/Users.pm18
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/VNDB/Handler/Users.pm b/lib/VNDB/Handler/Users.pm
index 09f148d5..5449669f 100644
--- a/lib/VNDB/Handler/Users.pm
+++ b/lib/VNDB/Handler/Users.pm
@@ -6,6 +6,7 @@ use warnings;
use TUWF ':html', 'xml_escape';
use VNDB::Func;
use VNDB::Types;
+use VNWeb::Auth;
use POSIX 'floor';
use PWLookup;
@@ -421,7 +422,7 @@ sub edit {
return $self->htmlDenied if !$self->authInfo->{id} || $self->authInfo->{id} != $uid && !$self->authCan('usermod');
# fetch user info (cached if uid == loggedin uid)
- my $u = $self->authInfo->{id} == $uid ? $self->authInfo : $self->dbUserGet(uid => $uid, what => 'extended prefs')->[0];
+ my $u = $self->dbUserGet(uid => $uid, what => 'extended prefs')->[0];
return $self->resNotFound if !$u->{id};
# check POST data
@@ -466,9 +467,9 @@ sub edit {
my $perm = 0;
$perm |= $self->{permissions}{$_} for(@{ delete $frm->{perms} });
- $self->dbUserSetPerm($u->{id}, $self->authInfo->{id}, $self->authInfo->{token}, $perm);
+ $self->dbUserSetPerm($u->{id}, $self->authInfo->{id}, auth->token(), $perm);
}
- $self->dbUserSetMail($u->{id}, $self->authInfo->{id}, $self->authInfo->{token}, $frm->{mail});
+ $self->dbUserSetMail($u->{id}, $self->authInfo->{id}, auth->token(), $frm->{mail});
$self->dbUserEdit($uid, %o);
$self->authAdminSetPass($u->{id}, $frm->{usrpass}) if $frm->{usrpass} && $self->authInfo->{id} != $u->{id};
@@ -485,7 +486,7 @@ sub edit {
# fill out default values
$frm->{usrname} ||= $u->{username};
- $frm->{mail} ||= $self->dbUserGetMail($u->{id}, $self->authInfo->{id}, $self->authInfo->{token});
+ $frm->{mail} ||= $self->dbUserGetMail($u->{id}, $self->authInfo->{id}, auth->token);
$frm->{perms} ||= [ grep $u->{perm} & $self->{permissions}{$_}, keys %{$self->{permissions}} ];
$frm->{$_} //= $u->{prefs}{$_} for(qw|skin customcss show_nsfw traits_sexual tags_all hide_list spoilers|);
$frm->{tags_cat} ||= [ split /,/, $u->{prefs}{tags_cat}||$self->{default_tags_cat} ];
@@ -545,8 +546,8 @@ sub edit {
sub posts {
my($self, $uid) = @_;
- # fetch user info (cached if uid == loggedin uid)
- my $u = $self->authInfo->{id} && $self->authInfo->{id} == $uid ? $self->authInfo : $self->dbUserGet(uid => $uid, what => 'hide_list')->[0];
+ # fetch user info
+ my $u = $self->dbUserGet(uid => $uid, what => 'hide_list')->[0];
return $self->resNotFound if !$u->{id};
my $f = $self->formValidate(
@@ -713,8 +714,8 @@ sub list {
sub notifies {
my($self, $uid) = @_;
- my $u = $self->authInfo;
- return $self->htmlDenied if !$u->{id} || $uid != $u->{id};
+ my $u = $self->dbUserGet(uid => $uid)->[0];
+ return $self->htmlDenied if !$u->{id} || $uid != $self->authInfo->{id};
my $f = $self->formValidate(
{ get => 'p', required => 0, default => 1, template => 'page' },
@@ -746,7 +747,6 @@ sub notifies {
my @ids = grep $_, @{$frm->{notifysel}};
$self->dbNotifyMarkRead(@ids) if @ids && $frm->{markread};
$self->dbNotifyRemove(@ids) if @ids && $frm->{remove};
- $self->authInfo->{notifycount} = $self->dbUserGet(uid => $uid, what => 'notifycount')->[0]{notifycount};
}
my($list, $np) = $self->dbNotifyGet(