Skip to content

Commit 55b6f3e

Browse files
committed
readme: typos
1 parent a07f013 commit 55b6f3e

File tree

1 file changed

+15
-19
lines changed

1 file changed

+15
-19
lines changed

readme.md

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ $user->logout();
6161

6262
Simple, right?
6363

64-
.[note]
6564
Logging in requires users to have cookies enabled - other methods are not safe!
6665

6766
Besides logging the user out with the `logout()` method, it can be done automatically based on specified time interval or closing the browser window. For this configuration we have to call `setExpiration()` during the login process. As an argument, it takes a relative time in seconds, UNIX timestamp, or textual representation of time.
@@ -74,12 +73,11 @@ $user->setExpiration('30 minutes');
7473
$user->setExpiration('2 days');
7574
```
7675

77-
.[note]
78-
Expiration must be set to value equal or lower than the expiration of [sessions].
76+
Expiration must be set to value equal or lower than the expiration of sessions.
7977

8078
The reason of last logout can be obtained by method `$user->getLogoutReason()`, which returns one of these constants: `IUserStorage::INACTIVITY` if time expired or `IUserStorage::MANUAL` when the `logout()` method was called.
8179

82-
To make the example above work, we in fact have to create an object that verifies user's name and password. It's called **authenticator**. Its trivial implementation is the class [api:Nette\Security\SimpleAuthenticator], which in its constructor accepts an associative array:
80+
To make the example above work, we in fact have to create an object that verifies user's name and password. It's called **authenticator**. Its trivial implementation is the class Nette\Security\SimpleAuthenticator, which in its constructor accepts an associative array:
8381

8482
```php
8583
$authenticator = new Nette\Security\SimpleAuthenticator(array(
@@ -89,7 +87,7 @@ $authenticator = new Nette\Security\SimpleAuthenticator(array(
8987
$user->setAuthenticator($authenticator);
9088
```
9189

92-
If the login credentials are not valid, authenticator throws an [api:Nette\Security\AuthenticationException]:
90+
If the login credentials are not valid, authenticator throws an Nette\Security\AuthenticationException:
9391

9492
```php
9593
try {
@@ -103,22 +101,21 @@ try {
103101
}
104102
```
105103

106-
We usually configure authenticator inside a [config file |configuring], which only creates the object if it's requested by the application. The example above would be set in `config.neon` as follows:
104+
We usually configure authenticator inside a config file, which only creates the object if it's requested by the application. The example above would be set in `config.neon` as follows:
107105

108106
```
109-
common:
110-
services:
111-
authenticator: Nette\Security\SimpleAuthenticator([
112-
john: IJ^%4dfh54*
113-
kathy: 12345
114-
])
107+
services:
108+
authenticator: Nette\Security\SimpleAuthenticator([
109+
john: IJ^%4dfh54*
110+
kathy: 12345
111+
])
115112
```
116113

117114

118115
Custom authenticator
119116
--------------------
120117

121-
We will create a custom authenticator that will check validity of login credentials against a database table. Every authenticator must be an implementation of [api:Nette\Security\IAuthenticator], with its only method `authenticate()`. Its only purpose is to return an [identity | #identity] or to throw an `Nette\Security\AuthenticationException`. Framework defines few error codes, that can be used to determine the reason login was not successful, such as self-explaining `IAuthenticator::IDENTITY_NOT_FOUND` or `IAuthenticator::INVALID_CREDENTIAL`.
118+
We will create a custom authenticator that will check validity of login credentials against a database table. Every authenticator must be an implementation of Nette\Security\IAuthenticator, with its only method `authenticate()`. Its only purpose is to return an identity or to throw an `Nette\Security\AuthenticationException`. Framework defines few error codes, that can be used to determine the reason login was not successful, such as self-explaining `IAuthenticator::IDENTITY_NOT_FOUND` or `IAuthenticator::INVALID_CREDENTIAL`.
122119

123120
```php
124121
use Nette\Security as NS;
@@ -151,7 +148,7 @@ class MyAuthenticator implements NS\IAuthenticator
151148
}
152149
```
153150

154-
Class `MyAuthenticator` communicates with the database using [Nette\Database |database] layer and works with table `users`, where it grabs `username` and hash of `password` in the appropriate columns. If the password check is successful, it returns new identity with user ID and role, which we will mention [later | #roles];
151+
Class `MyAuthenticator` communicates with the database using Nette\Database layer and works with table `users`, where it grabs `username` and hash of `password` in the appropriate columns. If the password check is successful, it returns new identity with user ID and role, which we will mention later;
155152

156153
This authenticator would be configured in the `config.neon` file like this:
157154

@@ -165,12 +162,12 @@ common:
165162
Identity
166163
--------
167164

168-
Identity presents a set of user information, as returned by autheticator. It's an object implementing [api:Nette\Security\IIdentity] interface, with default implementation [api:Nette\Security\Identity].
165+
Identity presents a set of user information, as returned by autheticator. It's an object implementing Nette\Security\IIdentity interface, with default implementation Nette\Security\Identity.
169166
Class has methods `getId()`, that returns users ID (for example primary key for the respective database row), and `getRoles()`, which returns an array of all roles user is in. User data can be access as if they were identity properties.
170167

171168
Identity is not erased when the user is logged out. So, if identity exists, it by itself does not grant that the user is also logged in. If we would like to explicitly delete the identity for some reason, we logout the user by calling `$user->logout(true)`.
172169

173-
Service `user` of class [api:Nette\Security\User] keeps the identity in session and uses it to all authorizations.
170+
Service `user` of class Nette\Security\User keeps the identity in session and uses it to all authorizations.
174171
Identity can be access with `getIdentity` upon `$user`:
175172

176173
```php
@@ -217,7 +214,7 @@ As you already know, logging user out does not erase his identity. Therefore the
217214
Authorizator
218215
------------
219216

220-
Authorizator decides, whether the user has permission to take some action. It's an implementation of [api:Nette\Security\IAuthorizator] interface with only one method `isAllowed()`. Purpose of this method is to determine, whether given role has the permission to perform certain *operation* with specific *resource*.
217+
Authorizator decides, whether the user has permission to take some action. It's an implementation of Nette\Security\IAuthorizator interface with only one method `isAllowed()`. Purpose of this method is to determine, whether given role has the permission to perform certain *operation* with specific *resource*.
221218

222219
- **role** is a user attribute - for example moderator, editor, visitor, registered user, administrator, ...
223220
- **resource** is a logical unit of the application - article, page, user, menu item, poll, presenter, ...
@@ -253,15 +250,14 @@ if ($user->isAllowed('file', 'delete')) { // is user allowed to delete a resourc
253250
}
254251
```
255252

256-
.[note]
257253
Do not confuse two different methods `isAllowed`: one belongs to the authorizator and the other one to the `User` class, where first argument is not `$role`.
258254

259255
Because user may have many roles, he is granted the permission only if at least one of roles has the permission. Both arguments are optional and their default value is *everything*.
260256

261257

262258
Permission ACL
263259
--------------
264-
Nette Framework has a complete authorizator, class [api:Nette\Security\Permission] which offers a light weight and flexible ACL((Access Control List)) layer for permission and access control. When we work with this class, we define roles, resources and individual privileges. Roles and resources may form hierarchies, as shown in the following example:
260+
Nette Framework has a complete authorizator, class Nette\Security\Permission which offers a light weight and flexible ACL((Access Control List)) layer for permission and access control. When we work with this class, we define roles, resources and individual privileges. Roles and resources may form hierarchies, as shown in the following example:
265261

266262
- `guest`: visitor that is not logged in, allowed to read and browse public part of the web, ie. articles, comments, and to vote in a poll
267263

0 commit comments

Comments
 (0)