NAME

CallBackery::User - tell me about the current user

SYNOPSIS

use CallBackery::User;
my $user = CallBackery::User->new($self->controller);

$user->werk;
$user->may('right'); # does the user have the given right
$user->id;

DESCRIPTION

All the methods if Mojo::Base as well as the following

$self->controller

the controller

$self->userId

By default the userId is numeric and represents a user account. For system tasks, it gets set to alphabetic identifiers. The following alphabetic identifiers do exist:

__CONSOLE when running in the config console mode
__CONFIG for backup and restore tasks

userId

return the user id if the session user is valid.

$self->mojoSqlDb

returns a pointer to one of the Database object of a Mojo::Pg instance.

$self->userInfo

returns a hash of information about the current user.

$self->loginName

returns a human readable login name for the current user

sessionExpired

True when a validly-signed session cookie was presented but is too old. Distinct from "not authenticated at all" (no/invalid cookie), which leaves this false. Set by cookieConf when a cookie is older than maxSessionAge, or by a subclass that enforces its own limit; read by the RPC dispatcher to choose the session-expired signal (code 7) over the login-required signal (code 6). Per-request.

maxSessionAge

How long a session is accepted after the login that started it, in seconds; 0 for no limit. Taken from max_session_age in the BACKEND section, no limit by default. Cookies renewed with makeSessionCookie keep the start of their session. Logging out does not invalidate a cookie that was already issued; this limit is what ends it.

$self->sessionConf

Extracts the session config from the cookie from the X-Session-Cookie header or the xsc parameter. If the xsc parameter is set, its timestamp must be no older than 2 seconds.

$user->login($login,$password)

login the user object. If login return 1 you can then makeSessionCookie.

$hash = $self->hashPassword($password)

Hash a password for the cbuser_password column: scrypt with a random salt over the NFC normalized, UTF-8 encoded password, stored as SCRYPT:N:r:p:salt:key. Hashes in the old unsalted HMAC-SHA1 format are still accepted by login, which replaces them on the next successful login.

$bool = $self->verifyPassword($hash,$password)

Check a password against a hash made by hashPassword.

$bool = $self->may(right);

Check if the user has the right indicated.

makeSessionCookie()

Returns a timestamped, signed session cookie containing the current userId.

COPYRIGHT

Copyright (c) 2013 by OETIKER+PARTNER AG. All rights reserved.

AUTHOR

Tobi Oetiker <tobi@oetiker.ch>

HISTORY

2010-06-12 to 1.0 initial
2013-11-19 to 1.1 mojo port