Skip to content

Commit

Permalink
docs: add note for authResult in channels
Browse files Browse the repository at this point in the history
  • Loading branch information
fratzinger committed Mar 29, 2023
1 parent 98e24cc commit b337e90
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
18 changes: 18 additions & 0 deletions docs/channels.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,24 @@ export default function (app) {
return;
}

// ...

app.on("login", (authResult: any, { connection }) => {
if (connection) {
// this is needed to map the ability from the authentication hook to the connection so it gets available in the HookContext as `params.ability` automatically
if (authResult.ability) {
connection.ability = authResult.ability;
connection.rules = authResult.rules;
}

// ...
}

// ...
});

// ...

const caslOptions = makeChannelOptions(app);

app.publish((data, context) => {
Expand Down
15 changes: 15 additions & 0 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,21 @@ export default function (app) {
// If no real-time functionality has been configured just return
return;
}
// ...

app.on("login", (authResult: any, { connection }) => {
if (connection) {
// this is needed to map the ability from the authentication hook to the connection so it gets available in the HookContext as `params.ability` automatically
if (authResult.ability) {
connection.ability = authResult.ability;
connection.rules = authResult.rules;
}

// ...
}
});

// ...

const caslOptions = makeChannelOptions(app);

Expand Down

0 comments on commit b337e90

Please sign in to comment.