Skip to content

Commit

Permalink
style: format
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Aug 25, 2020
1 parent 3eb1e59 commit a4905a2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 20 deletions.
40 changes: 21 additions & 19 deletions docs/docs/self-service/hooks.mdx
Expand Up @@ -5,13 +5,13 @@ title: Hooks

Hooks execute logic after a flow (login, registration, settings, ...):

- *After login:* is executed after a login was successful.
- *After registration:* is executed when a registration was successful:
- *Before persisting:* runs before the identity is saved in the database.
- *After persisting:* runs after the identity was saved in the database.
- *After settings:* is executed when a settings was successful:
- *Before persisting:* runs before the identity is saved in the database.
- *After persisting:* runs after the identity was saved in the database.
- _After login:_ is executed after a login was successful.
- _After registration:_ is executed when a registration was successful:
- _Before persisting:_ runs before the identity is saved in the database.
- _After persisting:_ runs after the identity was saved in the database.
- _After settings:_ is executed when a settings was successful:
- _Before persisting:_ runs before the identity is saved in the database.
- _After persisting:_ runs after the identity was saved in the database.

## Login

Expand Down Expand Up @@ -43,8 +43,8 @@ selfservice:

## Registration

Hooks running after successful user registration are defined per
Self-Service Registration Strategy in ORY Kratos' configuration file.
Hooks running after successful user registration are defined per Self-Service
Registration Strategy in ORY Kratos' configuration file.

### After

Expand All @@ -61,8 +61,8 @@ selfservice:

#### `session`

Adding the `session` hook signs the user immediately in once the account has been created.
It runs after the identity has been saved to the database.
Adding the `session` hook signs the user immediately in once the account has
been created. It runs after the identity has been saved to the database.

:::info

Expand All @@ -76,8 +76,9 @@ response.
:::

To use this hook, you must first define one or more (for secret rotation)
secrets. You can either choose to use the "default" secrets or the more specific "cookie" secrets.
The other required config is setting the hook in `after` work flows:
secrets. You can either choose to use the "default" secrets or the more specific
"cookie" secrets. The other required config is setting the hook in `after` work
flows:

```yaml title="path/to/my/kratos.config.yml"
secrets:
Expand Down Expand Up @@ -110,9 +111,9 @@ Therefore, the user is logged in immediately.

### Registration Flow via API

When performing a registration flow with an API client (e.g. mobile apo), this hook
creates a session and returns the session token and the session itself in the
response body as application/json:
When performing a registration flow with an API client (e.g. mobile apo), this
hook creates a session and returns the session token and the session itself in
the response body as application/json:

```json
{
Expand All @@ -130,9 +131,10 @@ response body as application/json:

:::info

Because the HTTP reply is handled by the hook itself, no other hooks can be executed because the HTTP
reply can not be modified further (e.g. HTTP Status Code was already sent as 200 and cannot be changed to 301).
You must ensure that the session hook is the last hook in your configuration!
Because the HTTP reply is handled by the hook itself, no other hooks can be
executed because the HTTP reply can not be modified further (e.g. HTTP Status
Code was already sent as 200 and cannot be changed to 301). You must ensure that
the session hook is the last hook in your configuration!

:::

Expand Down
1 change: 1 addition & 0 deletions x/config.go
Expand Up @@ -2,6 +2,7 @@ package x

import (
"github.com/gobuffalo/packr/v2"

"github.com/ory/x/logrusx"
"github.com/ory/x/viperx"
)
Expand Down
3 changes: 2 additions & 1 deletion x/nosurf.go
Expand Up @@ -5,9 +5,10 @@ import (
"net/http"

"github.com/justinas/nosurf"
"github.com/ory/x/randx"
"github.com/pkg/errors"

"github.com/ory/x/randx"

"github.com/ory/x/logrusx"
"github.com/ory/x/stringsx"

Expand Down

0 comments on commit a4905a2

Please sign in to comment.