
user_profile.pl -- User Profile Management
This module implements user profile management, in particular for
managing authentication and authorization for HTTP servers. It mainly
defines the interface that can be used within an HTTP application.
The actual storage is left to a plugin providing the backend
implementation. Backend choices may depend on integration needs with
other services, scale of the site (number of users), distribution, ease
of installation.
The typical setup sequence is
:- use_module(library(http/user_profile)).
:- use_module(library(http/impl/profile_prolog)).
:- set_setting(user_profile:backend, impl_profile_prolog).
:- multifile
user_profile:attribute/3.
user_profile:attribute_type(name, string, []).
...
profile_open_db(+Options) is det- Open the profile database. Must be called before any of the
other profile API predicates. Options depend on the used
backend.
profile_create(?ProfileID, +Attributes) is det- Create a new user profile with the given initial attributes.
- Arguments:
-
Attributes | - is a list of Name(Value) terms. |
profile_canonical_value(+Attribute, +ValueIn, -Value) is det- True when Value is the canonical value for Attribute that
satisfies the type constraint for Attribute.
- Errors
- -
type_error(Type, ValueIn)
if the type is wrong - -
existence_error(profile_attribute, Attribute)
if the
attribute is unknown.
current_profile(?ProfileID) is nondet- True when ProfileID is a currently known user profile.
current_profile(?ProfileID, -Attributes:dict) is nondet- True when ProfileID is a currently known user profile with the
given attributes.
profile_property(?ProfileID, ?Property:compound) is nondet- True when the user with ProfileID has Property. Property is a
term Name(Value).
set_profile(+ProfileID, +Attribute) is det
set_profile(+ProfileID, +Attribute, -Modified) is det- Set an attribute of the profile.
- Arguments:
-
Attribute | - is a term Name(Value) |
Modified | - is unified with a boolean, indicating whether
or not the value was modified. |
profile_remove(+ProfileID) is det- Completely destroy a profile.
profile_remove(+ProfileID, +Attribute) is det- Remove an attribute from a profile.
profile_add_session(+ProfileID, +SessionID, +Options) is det- Associate a profile with a session (login). Options defined are:
- timeout(+Seconds)
- Max idle time for the session.
- persistent(+Boolean)
- If
true
, store the session association persistently, such
that a server restart maintains the login.
profile_refresh_session(+ProfileID, +SessionID) is det- Update the last access time for the indicated session.
profile_remove_session(+ProfileID, +SessionID) is det- Remove the association of a profile with a session (logout).
profile_session(?ProfileID, ?SessionID) is nondet- True when ProfileID is associated (logged in) with SessionID.
error:has_type(+Type, +Value) is semidet[multifile]- True if Value satisfies Type. This implementation extends the
type logic defined in library(error) with some types that
commonly apply to user profiles.
- To be done
- - : extend with e.g., zip, country, phone, date
attribute(?Attribute, ?Type, ?Options) is nondet[multifile]- Multifile hook that defines that the profile attribute Attribute
must have the type Type. Type are types as defined by must_be/2
from library(error). Options defined are:
- access(+Access)
- Defines whether or not the user can update the attribute
value. Access is one of
rw
(default) or ro
.
- hidden(+Boolean)
- If
true
, the attribute is not displayed in the user
profile.
- default(+Value)
- Assumed default if the value is unknown.