NAME
WWW::Suffit::AuthDB::User - WWW::Suffit::AuthDB user class
SYNOPSIS
use WWW::Suffit::AuthDB::User;
DESCRIPTION
This module provides AuthDB user methods
ATTRIBUTES
This class implements the following attributes
address
address => '127.0.0.1'
The remote client IP address (IPv4 or IPv6)
$user = $user->address("::1");
my $address = $user->address;
Default: '127.0.0.1'
algorithm
$user = $user->algorithm( 'SHA256' );
my $algorithm = $user->algorithm;
Sets or returns algorithm of hash function for password store. See "password" attribute
Default: 'SHA256'
attributes
$user = $user->attributes( '{"foo": 123, "disabled": 0}' );
my $attributes = $user->attributes;
Sets or returns additional attributes of the user in JSON format
Default: none
cached
$user = $user->cached( 12345.123456789 );
my $cached = $user->cached;
Sets or returns time of caching user data
Default: 0
cachekey
$user = $user->cachekey( 'abcdef1234567890' );
my $cachekey = $user->cachekey;
Sets or returns the cache key string
comment
$user = $user->comment( 'Blah-Blah-Blah' );
my $comment = $user->comment;
Sets or returns comment for selected user
Default: undef
created
$user = $user->created( time() );
my $comment = $user->created;
Sets or returns time of user create
Default: 0
disabled
$user = $user->disabled( 1 );
my $disabled = $user->disabled;
Sets and returns boolean ban-status of the user
Since 1.01
this method is deprecated! See "is_enabled"
$user = $user->email('alice@example.com');
my $email = $user->email;
Sets and returns email address of user
error
$user = $user->error( 'Oops' );
my $error = $user->error;
Sets or returns error string
expires
$user = $user->expires( 300 );
my $expires = $user->expires;
Sets or returns cache/object expiration time in seconds
Default: 300 (5 min)
flags
$user = $user->flags( 123 );
my $flags = $user->flags;
Sets or returns flags of user
Default: 0
groups
$user = $user->groups([qw/ administrator wheel /]);
my $groups = $user->groups; # ['administrator', 'wheel']
Sets and returns groups of user (array of groups)
id
$user = $user->id( 2 );
my $id = $user->id;
Sets or returns id of user
Default: 0
is_authorized
This attribute returns true if the user is authorized
Default: false
is_cached
This attribute returns true if the user data was cached
Default: false
name
$user = $user->name('Mark Miller');
my $name = $user->name;
Sets and returns full name of user
not_after
$user = $user->not_after( time() );
my $not_after = $user->not_after;
Sets or returns the time after which user data is considered invalid
not_before
$user = $user->not_before( time() );
my $not_before = $user->not_before;
Sets or returns the time before which user data is considered invalid
password
$user = $user->password(sha256_hex('MyNewPassphrase'));
my $password = $user->password;
Sets and returns hex notation of user password digest (sha256, eg.). See "algorithm" attribute
private_key
$user = $user->private_key('...');
my $private_key = $user->private_key;
Sets and returns private key of user
public_key
$user = $user->public_key('...');
my $public_key = $user->public_key;
Sets and returns public key of user
role
$user = $user->role('Regular user');
my $role = $user->role;
Sets and returns role of user
username
$user = $user->username('new_username');
my $username = $user->username;
Sets and returns username
METHODS
This class inherits all methods from Mojo::Base and implements the following new ones
allow_ext
say "yes" if $user->allow_ext;
Returns true if user has access to external routes
allow_int
say "yes" if $user->allow_int;
Returns true if user has access to internal routes
forever
say "yes" if $user->forever;
Returns true if user can use endless API tokens
is_admin
say "yes" if $user->is_admin;
If user is admin then returns true
is_enabled
say "yes" if $user->is_enabled;
Returns status of user - enabled (true) or disabled (false)
is_valid
$user->is_valid or die "Incorrect user";
Returns boolean status of user's data
mark
Marks object as cached
to_hash
my $short = $user->to_hash();
my $full = $user->to_hash(1);
Returns user data as hash in short or full view
use_flags
say "yes" if $user->use_flags;
This method returns a binary indicator - whether flags should be used or not
HISTORY
See Changes
file
TO DO
See TODO
file
SEE ALSO
WWW::Suffit::AuthDB, Mojolicious
AUTHOR
Serż Minus (Sergey Lepenkov) https://www.serzik.com <abalama@cpan.org>
COPYRIGHT
Copyright (C) 1998-2025 D&D Corporation. All Rights Reserved
LICENSE
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See LICENSE
file and https://dev.perl.org/licenses/