Skip to content

Commit

Permalink
fix: Use new auth object in session example. (#181)
Browse files Browse the repository at this point in the history
Co-authored-by: Alexander Sandor <[email protected]>
  • Loading branch information
gazialankus and SandPod authored Jan 20, 2025
1 parent 29e35c4 commit bef4eab
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
5 changes: 3 additions & 2 deletions docs/06-concepts/11-authentication/02-basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

Serverpod automatically checks if the user is logged in and if the user has the right privileges to access the endpoint. When using the `serverpod_auth` module you will not have to worry about keeping track of tokens, refreshing them or, even including them in requests as this all happens automatically under the hood.

The `Session` object provides information about the current user. A unique `userId` identifies a user. You should use this id whenever you a referring to a user. Access the id of a signed-in user through the `authenticated` field of the `Session` object.
The `Session` object provides information about the current user. A unique `userId` identifies a user. You should use this id whenever you a referring to a user. Access the id of a signed-in user through the `authenticated` asynchronous getter of the `Session` object.

```dart
Future<void> myMethod(Session session) async {
var userId = (await session.authenticated)?.userId;
final authenticationInfo = await session.authenticated;
final userId = authenticationInfo?.userId;
...
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

Serverpod automatically checks if the user is logged in and if the user has the right privileges to access the endpoint. When using the `serverpod_auth` module you will not have to worry about keeping track of tokens, refreshing them or, even including them in requests as this all happens automatically under the hood.

The `Session` object provides information about the current user. A unique `userId` identifies a user. You should use this id whenever you a referring to a user. Access the id of a signed-in user through the `auth` field of the `Session` object.
The `Session` object provides information about the current user. A unique `userId` identifies a user. You should use this id whenever you a referring to a user. Access the id of a signed-in user through the `authenticated` asynchronous getter of the `Session` object.

```dart
Future<void> myMethod(Session session) async {
var userId = await session.auth.authenticatedUserId;
final authenticationInfo = await session.authenticated;
final userId = authenticationInfo?.userId;
...
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

Serverpod automatically checks if the user is logged in and if the user has the right privileges to access the endpoint. When using the `serverpod_auth` module you will not have to worry about keeping track of tokens, refreshing them or, even including them in requests as this all happens automatically under the hood.

The `Session` object provides information about the current user. A unique `userId` identifies a user. You should use this id whenever you a referring to a user. Access the id of a signed-in user through the `authenticated` field of the `Session` object.
The `Session` object provides information about the current user. A unique `userId` identifies a user. You should use this id whenever you a referring to a user. Access the id of a signed-in user through the `authenticated` asynchronous getter of the `Session` object.

```dart
Future<void> myMethod(Session session) async {
var userId = (await session.authenticated)?.userId;
final authenticationInfo = await session.authenticated;
final userId = authenticationInfo?.userId;
...
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

Serverpod automatically checks if the user is logged in and if the user has the right privileges to access the endpoint. When using the `serverpod_auth` module you will not have to worry about keeping track of tokens, refreshing them or, even including them in requests as this all happens automatically under the hood.

The `Session` object provides information about the current user. A unique `userId` identifies a user. You should use this id whenever you a referring to a user. Access the id of a signed-in user through the `authenticated` field of the `Session` object.
The `Session` object provides information about the current user. A unique `userId` identifies a user. You should use this id whenever you a referring to a user. Access the id of a signed-in user through the `authenticated` asynchronous getter of the `Session` object.

```dart
Future<void> myMethod(Session session) async {
var userId = (await session.authenticated)?.userId;
final authenticationInfo = await session.authenticated;
final userId = authenticationInfo?.userId;
...
}
```
Expand Down

0 comments on commit bef4eab

Please sign in to comment.