Usermanagement
Detailed Description
A complete role based user management implementation.Usage
After enabling user management, check if the UserController is correctly installed at /app/controllers/user.controller.php. If not, create your own, and derive it from UserBaseController. You can disable or enable features like user registration, login, mail on password loss etc. by overloading the function get_features_policy().The user management is roled based, whereas roles can be defined in table userroles. By default three roles are set: "Admin", "Editor", and "User". There also is a System user role, which however should not be assignable to users, so it is not stored in userroles table.
Users can have more than one role. They will always have at least one, though. This role is by default "User", you may change it by redefining APP_USER_DEFAULT_ROLE.
Routing and Caching
Use AccessRenderDecorator to allow access to a route only for logged in users or users with given roles. See UserBaseController for some examples.The AnonymousCacheManager should be used as default cache. It will disable cache for logged in users. Change /app/ww/index.php and replace creating the PageData instance with this code:
$cache_manager = new AnonymousCacheManager(); $page_data = new PageData($cache_manager, $_GET, $_POST);
- Attention:
- It is a common pitfall to forget this! Your users' data may become public if you do!
Views
If user management is enabled, all views are extended by two variables:- $current_user: The current user (DAOUsers) or false, if no user is logged in
- $is_logged_in: True if user is logged in, false otherwise
Pasword Hashing
The usermanagement offers several different password hashing methods. See ConfigUsermanagement for details. Default is "md5". This choice has been made for compatability reasons. Most likely, though, salted md5 (portable phpass) will become the default in the near future, since this is usually regarded more safe.You may however want to enable salted md5 right away. Do so by defining APP_USER_HASH_TYPE:
define('APP_USER_HASH_TYPE', 'pas2p');
The system will automatically update the password hash on login, if a user's hash type differs from the default one. This makes it safe to change the hash type at any time.
Update from 0.5 to 0.5.1 or later
With 0.5.1 release a "hash_type" field has been added to users table, along with some changes regarding DB consistency. If you do not use Systemupdate module, please run the SQL in [module]/install/updates/0001_hash_type.sql manually.Additionally, some changes have been made to the config options. Namely
- Usermanagement config moved to Config class
- Names of configuration defines have been unified:
- USER_DEFAULT_ROLE => APP_USER_DEFAULT_ROLE
- APP_DEFAULT_PAGE_USER => APP_USER_APP_DEFAULT_PAGE
- APP_DEFAULT_PAGE_ADMIN => has been removed
If you are not sure, if this has consequences for your code, set APP_VERSION_MAX to 0.5:
define('APP_VERSION_MAX', 0.5);
This will enable a compatibility layer. In most cases, however, transition should be smooth, since default values usually don't get modified.
Classes |
|
| class | AccessRenderDecorator |
| Allow access only for logged in users (of
given role). More... |
|
| class | AdminDashboard |
| Default dashboard implementation for admins.
More... |
|
| class | AnonymousCacheManager |
| Cache manager that caches only
if user is not logged in. More... |
|
| class | ChangeemailConfirmationHandler |
| Confirm email change. More... |
|
| class | ConfigUsermanagement |
| Usermanagement config options. More... |
|
| class | CreateaccountConfirmationHandler |
| Confirm account creation. More... |
|
| class | CreatePermanentloginsCommand |
| Create a permanent login. More... |
|
| class | CreateUsersBaseCommand |
| Create a user command to be overloaded.
More... |
|
| class | CreateUsersCommand |
| Create a user. More... |
|
| class | DAOPermanentlogins |
| Table Definition for permanentlogins.
More... |
|
| class | DAOSystemUsers |
| A fake user class to use as system user.
More... |
|
| class | DAOUserroles |
| Table Definition for userroles. More... |
|
| class | DAOUsers |
| Table Definition for users. More... |
|
| class | DashboardBase |
| Dashboard base class. More... |
|
| class | DefaultDashboard |
| Default dashboard for all users. More... |
|
| class | EditorDashboard |
| Default dashboard for editor. More... |
|
| class | EndPermanentloginsCommand |
| End a permanent login. More... |
|
| class | FilterUsername |
| Filter name and emial for user
name. More... |
|
| interface | IDashboard |
| Interface for Dashboard implementations.
More... |
|
| interface | IHashAlgorithm |
| Interface for Hash algorithm
implementations. More... |
|
| class | LoginknownUsersBaseCommand |
| Login known user command to be overloaded.
More... |
|
| class | LoginknownUsersCommand |
| Login known user. More... |
|
| class | LoginUsersBaseCommand |
| Login command to be overloaded. More... |
|
| class | LoginUsersCommand |
| Login. More... |
|
| class | LogoutUsersBaseCommand |
| Logout command to be overloaded. More... |
|
| class | LogoutUsersCommand |
| Logout. More... |
|
| class | Md5Hash |
| Calculates an MD5 hash. More... |
|
| class | OnetimeloginConfirmationHandler |
| Confirm onetime login (lost password).
More... |
|
| class | Pas2fHash |
| Calculates a hash using PHPPass 0.2 in full
mode. More... |
|
| class | Pas2pHash |
| Calculates a hash using PHPPass 0.2 in
portable mode. More... |
|
| class | PermanentLogins |
| Helper functions around permant logins.
More... |
|
| class | RegisterUsersBaseCommand |
| Register command to be overloaded. More... |
|
| class | RegisterUsersCommand |
| Register. More... |
|
| class | RestartsessionUsersBaseCommand |
| Restart session before logign in user -
created salted session id. More... |
|
| class | RestartsessionUsersCommand |
| Login. More... |
|
| class | Sha1Hash |
| Calculates an SHA1 hash. More... |
|
| class | StatusAnyUsersCommand |
| Command to set status. More... |
|
| class | UpdateUsersBaseCommand |
| Update a user. More... |
|
| class | UpdateUsersCommand |
| Update a user. More... |
|
| class | UserBaseController |
| Basic user controller, offers log in, logout
etc. More... |
|
| class | UserRoles |
| Helpers for user role retrieval. More... |
|
| class | Users |
| Usermanagement Business Logic. More... |
|
| class | UsersAccessControl |
| User Access Control for Users.
More... |
|
| class | UsersViewEventSink |
| Catch view events to extend rendering.
More... |
|
| class | ValidateUsersBaseCommand |
| Validate a user before create, update etc.
More... |
|
| class | ValidateUsersCommand |
| Validate a user. More... |
|
Functions |
|
| users_load_translations ($languages) | |
| Users translations. |
|
Function Documentation
| users_load_translations | ( | $ | languages | ) |
Users translations.
Definition at line 8 of file users.translations.php.
00008 { 00009 return array( 00010 'E-mail' => array( 00011 'de' => 'E-Mail' 00012 ), 00013 'Registered since' => array( 00014 'de' => 'Mitglied seit' 00015 ), 00016 'Username or password are wrong. Please try again.' => array( 00017 'de' => 'Benutzername oder Passwort waren falsch. Bitte versuchen Sie es noch einmal.' 00018 ), 00019 'Your account has not yet been activated' => array( 00020 'en' => 'Your account has not yet been activated. Please activate it using the url that has been mailed to you.', 00021 'de' => 'Ihr Zugang wurde noch nicht aktiviert. Bitte aktivieren Sie Ihren Zugang mit dem Link, der Ihnen per E-Mail zugegangen ist.' 00022 ), 00023 'Activation code could not be created' => array( 00024 'en' => 'Activation code could not be created. Please try again', 00025 'de' => 'Aktivierungscode konnte nicht erzeugt werden. Bitte versuchen Sie es noch einmal.' 00026 ), 00027 'No password' => array( 00028 'en' => 'Please enter a password', 00029 'de' => 'Bitte geben Sie Ihr Passwort ein' 00030 ), 00031 'Your registration' => array( 00032 'de' => 'Ihre Registrierung' 00033 ), 00034 'Change e-mail address' => array( 00035 'de' => 'E-Mail-Adresse ändern' 00036 ), 00037 'Administer catalogue' => array( 00038 'de' => 'Katalog verwalten' 00039 ), 00040 'My catalogue' => array( 00041 'de' => 'Mein Katalog' 00042 ), 00043 'Edit and administer entries and user settings' => array( 00044 'de' => 'Einträge und Benutzereinstellungen ändern und verwalten' 00045 ), 00046 'Login' => array( 00047 'de' => 'Anmelden' 00048 ), 00049 'Log into %app%' => array( 00050 'de' => 'In %app% einloggen' 00051 ), 00052 'Register' => array( 00053 'de' => 'Registrieren' 00054 ), 00055 'Registered user can add and edit entries' => array( 00056 'de' => 'Registrierte Benutzer können Einträge anlegen und ändern' 00057 ), 00058 'Logged in as %user%' => array( 00059 'de' => 'Angemeldet als %user%' 00060 ), 00061 'Logout' => array( 00062 'de' => 'Abmelden' 00063 ), 00064 'Quit %app%' => array( 00065 'de' => '%app% verlassen' 00066 ), 00067 'Confirmation' => array( 00068 'de' => 'Bestätigung' 00069 ), 00070 'Edit user %name%' => array( 00071 'de' => 'Benutzerdaten für %name% ändern' 00072 ), 00073 'All users' => array( 00074 'de' => 'Alle Benutzer' 00075 ), 00076 'Already logged in' => array( 00077 'en' => 'You are already logged in', 00078 'de' => 'Sie sind bereits angemeldet' 00079 ), 00080 'Password and password confirmation are different' => array( 00081 'de' => 'Passwort und Bestätigung stimmen nicht überein' 00082 ), 00083 'Please agree to the Terms of Service' => array( 00084 'de' => 'Bitte stimmen Sie den Allgemeinen Geschäftsbedingungen sowie den Datenschutzbestimmungen zu.' 00085 ), 00086 'Your registration request has been created' => array( 00087 'de' => 'Ihre Registrierung wurde angelegt. Eine E-Mail mit Ihren Zugangsdaten sowie einem Bestätigungslink ist unterwegs.' 00088 ), 00089 'Your changes have been stored' => array( 00090 'de' => 'Ihre Änderungen wurden gespeichert' 00091 ), 00092 'admin' => array( 00093 'en' => 'Admin', 00094 'de' => 'Administrator' 00095 ), 00096 'user' => array( 00097 'en' => 'User', 00098 'de' => 'Normaler Benutzer' 00099 ), 00100 'editor' => array( 00101 'en' => 'Editor', 00102 'de' => 'Redakteur' 00103 ), 00104 'VALIDATOR' => array( 00105 'en' => 'Validator', 00106 'de' => 'Eingangsprüfer' 00107 ), 00108 'Admin' => array( 00109 'de' => 'Administrator' 00110 ), 00111 'User' => array( 00112 'de' => 'Normaler Benutzer' 00113 ), 00114 'Editor' => array( 00115 'de' => 'Redakteur' 00116 ), 00117 'Unconfirmed' => array( 00118 'de' => 'Nicht bestätigt' 00119 ), 00120 'Deleted' => array( 00121 'de' => 'Gelöscht' 00122 ), 00123 'Banned' => array( 00124 'de' => 'Gebannt' 00125 ), 00126 'Active' => array( 00127 'de' => 'Aktiv' 00128 ), 00129 'Edit User' => array( 00130 'de' => 'Benutzerdaten ändern' 00131 ), 00132 'Your account was set to "%status%"' => array( 00133 'de' => 'Ihr Account wurde auf "%status%" gesetzt' 00134 ), 00135 'Show User\'s Entries' => array( 00136 'de' => 'Einträge des Benutzers' 00137 ), 00138 'You are not allowed to login' => array( 00139 'de' => 'Sie haben kein Recht, sich anzumelden' 00140 ), 00141 'Edit Acount' => array( 00142 'de' => 'Zugangsdaten ändern' 00143 ), 00144 'Edit your account settings' => array( 00145 'de' => 'Benutzername und Password ändern' 00146 ), 00147 'An user with this email address aready exists' => array ( 00148 'de' => 'Es existiert bereits ein Benutzer mit dieser E-Mail-Adresse.' 00149 ), 00150 'Delete Account' => array( 00151 'de' => 'Mitgliedschaft beenden' 00152 ), 00153 'Delete your account' => array( 00154 'de' => 'Löscht Ihren Account und Ihre persönlichen Daten' 00155 ), 00156 'Your account has been deleted' => array( 00157 'de' => 'Ihre Mitgliedschaft wurde beendet und Ihre persönlichen Daten werden umgehend gelöscht' 00158 ), 00159 'No user set to delete' => array( 00160 'de' => 'Delete User Command: Es wurde kein Benutzer gesetzt' 00161 ), 00162 'User Role' => array( 00163 'de' => 'Berechtigung' 00164 ), 00165 'Lost password' => array( 00166 'de' => 'Passwort vergessen' 00167 ), 00168 'Your one time login request has been created' => array( 00169 'de' => 'Es wurde ein einmaliges Login für Sie eingerichtet. Bitte prüfen Sie Ihre E-Mail.' 00170 ), 00171 'Unknown email' => array( 00172 'de' => 'Unbekannte E-Mail-Adresse' 00173 ), 00174 'One time login' => array( 00175 'de' => 'Einmaliges automatisches Login' 00176 ), 00177 'Resend Activation Mail' => array( 00178 'de' => 'Aktivierungsmail erneut zuschicken' 00179 ), 00180 'Your activation information mail has been send to you again' => array( 00181 'de' => 'Ihre Aktivierungsmail wurde Ihnen erneut zugeschickt.' 00182 ), 00183 'Your account already has been activated, use you email address and password to log in.' => array( 00184 'de' => 'Ihr Zugang wurde bereits freigeschaltet. Melden Sie sich mit Ihrer E-Mail-Adresse und Ihrem Passwort an.' 00185 ), 00186 'You activation request already has expired.' => array( 00187 'de' => 'Ihre Aktivierung ist nicht länger gültig und wurde gelöscht.' 00188 ), 00189 'You are now logged in. Feel comfortable.' => array( 00190 'de' => 'Hallo! Sie sind nun eingeloggt.' 00191 ), 00192 'Please enter your username and password and click <strong>Login</strong>.' => array( 00193 'de' => 'Bitte geben Sie Ihren Benutzernamen und Ihr Passwort ein und drücken dann auf <strong>Anmelden</strong>.' 00194 ), 00195 'Forgot password?' => array( 00196 'de' => 'Passwort vergessen?' 00197 ), 00198 'Username:' => array( 00199 'de' => 'Benutzername:' 00200 ), 00201 'Password:' => array( 00202 'de' => 'Passwort:' 00203 ), 00204 'Registered, but got no confirmation mail?' => array( 00205 'de' => 'Registriert, aber noch keine Bestätigungs-Mail bekommen?' 00206 ), 00207 'Stay logged in.' => array( 00208 'de' => 'Eingeloggt bleiben, nachdem der Browser geschlossen wurde' 00209 ), 00210 'Click here to become a member.' => array( 00211 'de' => 'Klicken Sie hier, um Mitglied zu werden' 00212 ), 00213 'Welcome! You are now logged in.' => array( 00214 'de' => 'Willkommen! Sie sind nun eingeloggt.' 00215 ), 00216 'Application Management' => array( 00217 'de' => 'Administration' 00218 ), 00219 'Your links' => array( 00220 'de' => 'Persönliche Einstellungen' 00221 ), 00222 'List unconfirmed users' => array( 00223 'de' => 'Unbestätigte Benutzer auflisten' 00224 ), 00225 'List all users' => array( 00226 'de' => 'Alle Benutzer auflisten' 00227 ), 00228 'Edit your account' => array( 00229 'de' => 'Benutzerdaten ändern' 00230 ), 00231 'Welcome %name' => array( 00232 'de' => 'Willkommen, %name!' 00233 ), 00234 'Not registered yet?' => array( 00235 'de' => 'Noch kein Mitglied?' 00236 ), 00237 'Your personal site' => array( 00238 'de' => 'Kontrollzentrum' 00239 ), 00240 'Content Management' => array( 00241 'de' => 'Inhalte verwalten' 00242 ), 00243 'User Menu' => array( 00244 'de' => 'Benutzermenu' 00245 ), 00246 'You have been logged out' => array( 00247 'de' => 'Sie wurden abgemeldet' 00248 ), 00249 'Become a member' => array( 00250 'de' => 'Mitglied werden' 00251 ), 00252 'Fill in the fields and click <strong>Register</strong> to become a member. You will get an e-mail with a confirmation link afterwards.' => array( 00253 'de' => 'Füllen Sie die Felder aus und klicken anschließend <strong>Registrieren</strong> um ein Mitglied zu werden. Sie bekommen anschließend eine E-Mail mit einem Bestätigungslink.' 00254 ), 00255 'If you enter your e-mail address, the system will send you a link to log you in for once. You then will be able to change your password.' => array( 00256 'de' => 'Geben Sie Ihre E-Mail-Adresse ein. Das System schickt Ihnen einen Link, mit dem Sie sich einmalig einloggen können. Dort können Sie dann Ihr Passwort ändern.' 00257 ), 00258 'Please enter your e-mail address and click <strong>Submit</strong> afterwards.' => array( 00259 'de' => 'Bitte geben Sie Ihre E-Mail-Adresse ein und klicken anschließend auf <strong>Absenden</strong>' 00260 ), 00261 'Submit' => array( 00262 'de' => 'Absenden' 00263 ), 00264 'Lost Password' => array( 00265 'de' => 'Passwort vergessen' 00266 ), 00267 'If you registered but did not receive an activation e-mail, you can force the mail to be resend by filling out the form and clicking on <strong>Resend</strong> below' => array( 00268 'de' => 'Wenn Sie sich registriert haben, aber keine Aktivierungs-E-Mail bekommen haben, können Sie sich diese hier erneut zuschicken lassen. Tragen Sie dazu Ihre E-Mail-Adresse und klicken dann auf <strong>Erneut zusenden</strong>.' 00269 ), 00270 'Please check, if the mail has been blocked as spam, before trying to resend.' => array( 00271 'de' => 'Bitte prüfen Sie vorher, ob Ihr Mail-Programm oder Ihr Mail-Provider die Aktivierungsnachricht irrtümlich als Spam eingestuft haben.' 00272 ), 00273 'Resend' => array( 00274 'de' => 'Erneut zusenden' 00275 ), 00276 'Edit' => array( 00277 'de' => 'Bearbeiten' 00278 ), 00279 'Change Account Data' => array( 00280 'de' => 'Benutzerkonto Bearbeiten' 00281 ), 00282 'Fill out the fields below and click <strong>Save</strong> to save your data.' => array( 00283 'de' => 'Füllen Sie die Felder aus und klicken Sie dann <strong>Speichern</strong> um die Daten zu übernehmen.' 00284 ), 00285 'If the e-mail changes, you will get a mail send to the new address to confirm this address exists.' => array( 00286 'de' => 'Wenn sich Ihre E-Mail-Adresse ändert erhalten Sie eine Mail an die neue Adresse, um diese zu verifizieren.' 00287 ), 00288 'Repeat Password:' => array( 00289 'de' => 'Passwort wiederholen:' 00290 ), 00291 'Leave these fields empty to not change the password.' => array( 00292 'de' => 'Lassen Sie deise Felder leer um das Passwort nicht zu ändern.' 00293 ), 00294 'E-mail:' => array( 00295 'de' => 'E-Mail:' 00296 ), 00297 'Save' => array( 00298 'de' => 'Speichern' 00299 ), 00300 'Users' => array( 00301 'de' => 'Benutzer' 00302 ) 00303 ); 00304 }
