PublicShow -- 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_type(name, string, []).
Source 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.
Source profile_create(?ProfileID, +Attributes) is det
Create a new user profile with the given initial attributes.
Attributes- is a list of Name(Value) terms.
Source profile_canonical_value(+Attribute, +ValueIn, -Value) is det
True when Value is the canonical value for Attribute that satisfies the type constraint for Attribute.
- type_error(Type, ValueIn) if the type is wrong
- existence_error(profile_attribute, Attribute) if the attribute is unknown.
Source current_profile(?ProfileID) is nondet
True when ProfileID is a currently known user profile.
Source current_profile(?ProfileID, -Attributes:dict) is nondet
True when ProfileID is a currently known user profile with the given attributes.
Source profile_property(?ProfileID, ?Property:compound) is nondet
True when the user with ProfileID has Property. Property is a term Name(Value).
Source set_profile(+ProfileID, +Attribute) is det
Source set_profile(+ProfileID, +Attribute, -Modified) is det
Set an attribute of the profile.
Attribute- is a term Name(Value)
Modified- is unified with a boolean, indicating whether or not the value was modified.
Source profile_remove(+ProfileID) is det
Completely destroy a profile.
Source profile_remove(+ProfileID, +Attribute) is det
Remove an attribute from a profile.
Source profile_add_session(+ProfileID, +SessionID, +Options) is det
Associate a profile with a session (login). Options defined are:
Max idle time for the session.
If true, store the session association persistently, such that a server restart maintains the login.
Source profile_refresh_session(+ProfileID, +SessionID) is det
Update the last access time for the indicated session.
Source profile_remove_session(+ProfileID, +SessionID) is det
Remove the association of a profile with a session (logout).
Source profile_session(?ProfileID, ?SessionID) is nondet
True when ProfileID is associated (logged in) with SessionID.
Source 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
Source 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:
Defines whether or not the user can update the attribute value. Access is one of rw (default) or ro.
If true, the attribute is not displayed in the user profile.
Assumed default if the value is unknown.