summaryrefslogtreecommitdiff
path: root/lib/VNWeb/Auth.pm
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2019-10-08 18:16:46 +0200
committerYorhel <git@yorhel.nl>2019-10-10 16:40:30 +0200
commitb3a9130763879d60c0e413c724a759860bd396af (patch)
tree2de6f9d21d4ce9f00fc11595906570be43d8ae5c /lib/VNWeb/Auth.pm
parent4c1dfc8bb62171c4c21057c47f238c8747bac3f8 (diff)
rewards: Apply supporters badge and unicode name (almost) everywhere
Only place where this isn't applied (yet?): Sorting user lists still goes by the old username and board names don't use the new unicode names. I have to say, I quite like the sql_user() and user_() pattern. It's not without problems when applied to everything, but it's good enough for several use cases.
Diffstat (limited to 'lib/VNWeb/Auth.pm')
-rw-r--r--lib/VNWeb/Auth.pm25
1 files changed, 11 insertions, 14 deletions
diff --git a/lib/VNWeb/Auth.pm b/lib/VNWeb/Auth.pm
index 7143f203..bd1fba49 100644
--- a/lib/VNWeb/Auth.pm
+++ b/lib/VNWeb/Auth.pm
@@ -11,7 +11,6 @@
# auth->logout;
#
# my $uid = auth->uid;
-# my $username = auth->username;
# my $wants_spoilers = auth->pref('spoilers');
# ..etc
#
@@ -56,17 +55,17 @@ TUWF::hook after => sub { $auth = __PACKAGE__->new() };
# have a lot of influence in this)
TUWF::set log_format => sub {
my(undef, $uri, $msg) = @_;
- sprintf "[%s] %s %s: %s\n", scalar localtime(), $uri, auth ? auth->uid : '-', $msg;
+ sprintf "[%s] %s %s: %s\n", scalar localtime(), $uri, auth ? 'u'.auth->uid : '-', $msg;
};
-use overload bool => sub { defined shift->{uid} };
+use overload bool => sub { defined shift->{user}{user_id} };
-sub uid { shift->{uid} }
-sub username { shift->{username} }
-sub perm { shift->{perm}||0 }
-sub token { shift->{token} }
+sub uid { shift->{user}{user_id} }
+sub perm { shift->{user}{perm}||0 }
+sub user { shift->{user} }
+sub token { shift->{token} }
@@ -150,18 +149,16 @@ sub _load_session {
my($self, $uid, $token_db) = @_;
my $user = $uid ? tuwf->dbRowi(
- 'SELECT id, username, perm FROM users
+ 'SELECT perm, ', sql_user(), ' FROM users u
WHERE id = ', \$uid,
'AND', sql_func(user_isvalidsession => 'id', sql_fromhex($token_db), \'web')
) : {};
# Drop the cookie if it's not valid
- tuwf->resCookie(auth => undef) if !$user->{id} && tuwf->reqCookie('auth');
+ tuwf->resCookie(auth => undef) if !$user->{user_id} && tuwf->reqCookie('auth');
- $self->{uid} = $user->{id};
- $self->{username} = $user->{username};
- $self->{perm} = $user->{perm}||0;
- $self->{token} = $token_db;
+ $self->{user} = $user;
+ $self->{token} = $token_db;
delete $self->{pref};
}
@@ -279,7 +276,7 @@ sub csrfcheck {
my @pref_columns = qw/
email_confirmed skin customcss filter_vn filter_release show_nsfw hide_list notify_dbedit notify_announce
- vn_list_own vn_list_wish tags_all tags_cont tags_ero tags_tech spoilers traits_sexual
+ vn_list_own vn_list_wish tags_all tags_cont tags_ero tags_tech spoilers traits_sexual nodistract_can nodistract_nofancy
/;
# Returns a user preference column for the current user. Lazily loads all