Skip to content

Commit

Permalink
changes from docs review
Browse files Browse the repository at this point in the history
  • Loading branch information
Rishabh committed Jul 6, 2021
1 parent ad163a9 commit 1792c42
Show file tree
Hide file tree
Showing 17 changed files with 23 additions and 125 deletions.
3 changes: 1 addition & 2 deletions auth-react/docs/emailpassword/email-password-auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ __HIGHLIGHT__ return (
- `EmailPasswordAuth` will update the session, because it uses `SessionAuth` underneath. Read more about session updates in [SessionAuth guide](../session/session-auth).

## Handle session expiry
If you pass function to `onSessionExpired` prop, it will be called whenever session expires. This will also prevent
children from receiving `SessionContext` update, so that you can preserve the UI for authenticated user to improve UX.
If you pass a function to `onSessionExpired` prop, it will be called whenever the session expires. This will also prevent children from receiving `SessionContext` update, so that you can preserve the UI for authenticated user.

Example:
```tsx
Expand Down
3 changes: 1 addition & 2 deletions auth-react/docs/session/session-auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ const App = () => {
```

### Respond to session expiry
If you pass function as `onSessionExpired` prop, it will be called whenever session expires.
**When session expires this will prevent `SessionContext` from updating**. This means you can still display the UI for authenticated user.
If you pass a function as `onSessionExpired` prop, it will be called whenever session expires. **When session expires this will prevent `SessionContext` from updating**. This means you can still display the UI for authenticated user.

Example:
```tsx
Expand Down
3 changes: 1 addition & 2 deletions auth-react/docs/thirdparty/third-party-auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ __HIGHLIGHT__ return (
- `ThirdPartyAuth` will update the session, because it uses `SessionAuth` underneath. Read more about session updates in [SessionAuth guide](../session/session-auth).

## Handle session expiry
If you pass function to `onSessionExpired` prop, it will be called whenever session expires. This will also prevent
children from receiving `SessionContext` update, so that you can preserve the UI for authenticated user to improve UX.
If you pass a function to `onSessionExpired` prop, it will be called whenever the session expires. This will also prevent children from receiving `SessionContext` update, so that you can preserve the UI for authenticated user.

Example:
```tsx
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ __HIGHLIGHT__ return (
- `ThirdPartyEmailPasswordAuth` will update the session, because it uses `SessionAuth` underneath. Read more about session updates in [SessionAuth guide](../session/session-auth).

## Handle session expiry
If you pass function to `onSessionExpired` prop, it will be called whenever session expires. This will also prevent
children from receiving `SessionContext` update, so that you can preserve the UI for authenticated user to improve UX.
If you pass a function to `onSessionExpired` prop, it will be called whenever the session expires. This will also prevent children from receiving `SessionContext` update, so that you can preserve the UI for authenticated user.

Example:
```tsx
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,13 @@ you can pass function in `onSessionExpired` prop. This function will be called w
```tsx
const App = () => {
return (
<EmailPasswordAuth onSessionExpired={onSessionExpired}>
<EmailPasswordAuth onSessionExpired={showSessionExpiredPopup}>
<MyComponent />
</EmailPasswordAuth>
);
}
```

### Preserving the UI on session expiry
By passing `onSessionExpired` you are preventing the update to `SessionContext` that `MyComponent` would receive
when session expires. This allows you to handle session expiry while still displaying UI for authenticated user to improve UX.

Example:
```tsx
const App = () => {
return (
<EmailPasswordAuth onSessionExpired={displayLoginPopup}>
<MyComponent />
</EmailPasswordAuth>
);
};
```

If you don't specify the `onSessionExpired`, the default behaviour is redirecting the user to where they might sign in.
> You will need to either reload the current page or redirect the user to the sign in page if you provide this callback.
Read more about `EmailPasswordAuth` and `onSessionExpired` in [its API reference](/docs/auth-react/docs/emailpassword/email-password-auth).
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
id: securing-component
title: Securing component
title: Securing a website route / component
hide_title: true
---

# Securing a component
# Securing a website route / component
You may want to prevent rendering of some part of UI, or a route, when
there's no session.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,6 @@ render() {
);
}
```

### Automatic context updates
`SessionContext` will be updated for `EmailPasswordAuth` children whenever any of the following events happens:
- App is loaded or reloaded
- User signs in
- User signs out
- Session expires
- Session is refreshed

The only exception is when you use `onSessionExpired`, which is explained in [Handling session expiry](./handling-session-expiry).

You can read more about `EmailPasswordAuth` in [its API guide](/docs/auth-react/docs/emailpassword/email-password-auth)

## Without React context
```js
import Session from 'supertokens-auth-react/recipe/session';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ Session.init({
} else if (context.action === "UNAUTHORISED") {
// called when the session has expired
} else if (context.action === "SESSION_CREATED") {
// Called when session is created.
//
// It means that if session previously existed
// and it only gets refreshed, this event will not be fired
// Called when session is created - post login / sign up.
}
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,13 @@ you can pass function in `onSessionExpired` prop. This function will be called w
```tsx
const App = () => {
return (
<SessionAuth onSessionExpired={onSessionExpired}>
<SessionAuth onSessionExpired={showSessionExpiredPopup}>
<MyComponent />
</SessionAuth>
);
}
```

### Preserving the UI on session expiry
By passing `onSessionExpired` you are preventing the update to `SessionContext` that `MyComponent` would receive
when session expires. This allows you to handle session expiry while still displaying UI for authenticated user to improve UX.

Example:
```tsx
const App = () => {
return (
<SessionAuth onSessionExpired={displayLoginPopup}>
<MyComponent />
</SessionAuth>
);
};
```

If you don't specify the `onSessionExpired`, it will be handled by `redirectToLogin` by default.
> You will need to either reload the current page or redirect the user to the sign in page if you provide this callback.
Read more about `SessionAuth` and `onSessionExpired` in [its API reference](/docs/auth-react/docs/session/session-auth).
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
id: securing-component
title: Securing component
title: Securing a website route / component
hide_title: true
---

# Securing a component
# Securing a website route / component
You may want to prevent rendering of some part of UI, or a route, when
there's no session.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,6 @@ render() {
}
```

### Automatic context updates
`SessionContext` will be updated for `SessionAuth` children whenever any of the following events happens:
- App is loaded or reloaded
- User signs in
- User signs out
- Session expires
- Session is refreshed

The only exception is when you use `onSessionExpired`, which is explained in [Handling session expiry](./handling-session-expiry).

## Without React context
```js
import Session from 'supertokens-auth-react/recipe/session';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,13 @@ you can pass function in `onSessionExpired` prop. This function will be called w
```tsx
const App = () => {
return (
<ThirdPartyAuth onSessionExpired={onSessionExpired}>
<ThirdPartyAuth onSessionExpired={showSessionExpiredPopup}>
<MyComponent />
</ThirdPartyAuth>
);
}
```

### Preserving the UI on session expiry
By passing `onSessionExpired` you are preventing the update to `SessionContext` that `MyComponent` would receive
when session expires. This allows you to handle session expiry while still displaying UI for authenticated user to improve UX.

Example:
```tsx
const App = () => {
return (
<ThirdPartyAuth onSessionExpired={displayLoginPopup}>
<MyComponent />
</ThirdPartyAuth>
);
};
```

If you don't specify the `onSessionExpired`, the default behaviour is redirecting the user to where they might sign in.
> You will need to either reload the current page or redirect the user to the sign in page if you provide this callback.
Read more about `ThirdPartyAuth` and `onSessionExpired` in [its API reference](/docs/auth-react/docs/thirdparty/third-party-auth).
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
id: securing-component
title: Securing component
title: Securing a website route / component
hide_title: true
---

# Securing a component
# Securing a website route / component
You may want to prevent rendering of some part of UI, or a route, when
there's no session.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,6 @@ render() {
}
```

### Automatic context updates
`SessionContext` will be updated for `ThirdPartyAuth` children whenever any of the following events happens:
- App is loaded or reloaded
- User signs in
- User signs out
- Session expires
- Session is refreshed

The only exception is when you use `onSessionExpired`, which is explained in [Handling session expiry](./handling-session-expiry).

You can read more about `ThirdPartyAuth` in [its API guide](/docs/auth-react/docs/thirdparty/third-party-auth)

## Without React context
```js
import Session from 'supertokens-auth-react/recipe/session';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,13 @@ you can pass function in `onSessionExpired` prop. This function will be called w
```tsx
const App = () => {
return (
<ThirdPartyEmailPasswordAuth onSessionExpired={onSessionExpired}>
<ThirdPartyEmailPasswordAuth onSessionExpired={showSessionExpiredPopup}>
<MyComponent />
</ThirdPartyEmailPasswordAuth>
);
}
```

### Preserving the UI on session expiry
By passing `onSessionExpired` you are preventing the update to `SessionContext` that `MyComponent` would receive
when session expires. This allows you to handle session expiry while still displaying UI for authenticated user to improve UX.

Example:
```tsx
const App = () => {
return (
<ThirdPartyEmailPasswordAuth onSessionExpired={displayLoginPopup}>
<MyComponent />
</ThirdPartyEmailPasswordAuth>
);
};
```

If you don't specify the `onSessionExpired`, the default behaviour is redirecting the user to where they might sign in.
> You will need to either reload the current page or redirect the user to the sign in page if you provide this callback.
Read more about `ThirdPartyEmailPasswordAuth` and `onSessionExpired` in [its API reference](/docs/auth-react/docs/thirdpartyemailpassword/third-party-email-password-auth).
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
id: securing-component
title: Securing component
title: Securing a website route / component
hide_title: true
---

# Securing a component
# Securing a website route / component
You may want to prevent rendering of some part of UI, or a route, when
there's no session.

Expand Down
4 changes: 2 additions & 2 deletions website/docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ This library provides a wrapper around ```fetch``` or ```axios``` to automatical
## Using ```npm```

```bash
npm i --save supertokens-website@^8.0.0
npm i --save supertokens-website@^8.1.0
```


## Using ```<script>```
Put the following anywhere in your ```<head>``` tag

```html
<script src="https://cdn.jsdelivr.net/gh/supertokens/supertokens-website@8.0/bundle/bundle.js"></script>
<script src="https://cdn.jsdelivr.net/gh/supertokens/supertokens-website@8.1/bundle/bundle.js"></script>
```

0 comments on commit 1792c42

Please sign in to comment.