Skip to content

Commit 8dbfc24

Browse files
authored
Merge pull request #172 from kenjis/fix-docs-authentication.md
docs: fix authentication.md
2 parents 971966b + c2cb7cd commit 8dbfc24

1 file changed

Lines changed: 18 additions & 27 deletions

File tree

docs/2 - authentication.md

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ The default authenticator is also defined in the configuration file, and uses th
2424
public $defaultAuthenticator = 'session';
2525
```
2626

27-
### Auth Helper
27+
## Auth Helper
2828

2929
The auth functionality is designed to be used with the `auth_helper` that comes with Shield. This
3030
helper method provides the `auth()` command which returns a convenient interface to the most frequently
@@ -42,33 +42,33 @@ user_id()
4242
auth()->id()
4343
```
4444

45-
### Authenticator Responses
45+
## Authenticator Responses
4646

4747
Many of the authenticator methods will return a `CodeIgniter\Shield\Result` class. This provides a consistent
4848
way of checking the results and can have additional information return along with it. The class
4949
has the following methods:
5050

51-
#### isOK()
51+
### isOK()
5252

5353
Returns a boolean value stating whether the check was successful or not.
5454

55-
#### reason()
55+
### reason()
5656

5757
Returns a message that can be displayed to the user when the check fails.
5858

59-
#### extraInfo()
59+
### extraInfo()
6060

6161
Can return a custom bit of information. These will be detailed in the method descriptions below.
6262

6363

64-
### Session Authenticator
64+
## Session Authenticator
6565

6666
The Session authenticator stores the user's authentication within the user's session, and on a secure cookie
6767
on their device. This is the standard password-based login used in most web sites. It supports a
6868
secure remember me feature, and more. This can also be used to handle authentication for
6969
single page applications (SPAs).
7070

71-
#### attempt()
71+
### attempt()
7272

7373
When a user attempts to login with their email and password, you would call the `attempt()` method
7474
on the auth class, passing in their credentials.
@@ -107,7 +107,7 @@ to set a secure remember-me cookie.
107107
$loginAttempt = auth()->remember()->attempt($credentials);
108108
```
109109

110-
#### check()
110+
### check()
111111

112112
If you would like to check a user's credentials without logging them in, you can use the `check()`
113113
method.
@@ -127,7 +127,7 @@ if (! $validCreds->isOK()) {
127127

128128
The Result instance returned contains the logged in user as `extraInfo()`.
129129

130-
#### loggedIn()
130+
### loggedIn()
131131

132132
You can determine if a user is currently logged in with the aptly titled method, `loggedIn()`.
133133

@@ -137,7 +137,7 @@ if (auth()->loggedIn()) {
137137
}
138138
```
139139

140-
#### logout()
140+
### logout()
141141

142142
You can call the `logout()` method to log the user out of the current session. This will destroy and
143143
regenerate the current session, purge any remember-me tokens current for this user, and trigger a
@@ -147,18 +147,12 @@ regenerate the current session, purge any remember-me tokens current for this us
147147
auth()->logout();
148148
```
149149

150-
#### forget()
150+
### forget()
151151

152152
The `forget` method will purge all remember-me tokens for the current user, making it so they
153153
will not be remembered on the next visit to the site.
154154

155-
156-
157-
---
158-
159-
160-
161-
### Access Token Authenticator
155+
## Access Token Authenticator
162156

163157
The Access Token authenticator supports the use of revoke-able API tokens without using OAuth. These are commonly
164158
used to provide third-party developers access to your API. These tokens typically have a very long
@@ -169,8 +163,7 @@ with their email/password. The application would create a new access token for t
169163
name, like John's iPhone 12, and return it to the mobile application, where it is stored and used
170164
in all future requests.
171165

172-
173-
## Access Token/API Authentication
166+
### Access Token/API Authentication
174167

175168
Using access tokens requires that you either use/extend `CodeIgniter\Shield\Models\UserModel` or
176169
use the `CodeIgniter\Shield\Authentication\Traits\HasAccessTokens` on your own user model. This trait
@@ -291,13 +284,11 @@ These filters are already loaded for you by the registrar class located at `src/
291284

292285
```php
293286
public $aliases = [
294-
'csrf' => CSRF::class,
295-
'toolbar' => DebugToolbar::class,
296-
'honeypot' => Honeypot::class,
297-
'session' => CodeIgniter\Shield\Filters\SessionAuth::class,
298-
'tokens' => CodeIgniter\Shield\Filters\TokenAuth::class,
299-
'chain' => CodeIgniter\Shield\Filters\ChainAuth::class,
287+
// ...
288+
'session' => \CodeIgniter\Shield\Filters\SessionAuth::class,
289+
'tokens' => \CodeIgniter\Shield\Filters\TokenAuth::class,
290+
'chain' => \CodeIgniter\Shield\Filters\ChainAuth::class,
300291
];
301292
```
302293

303-
These can be used in any of the normal validation config settings, or within the routes file.
294+
These can be used in any of the normal filter config settings, or within the routes file.

0 commit comments

Comments
 (0)