@ciromaciel/auth-react 1.0.2 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -1
- package/dist/index.esm.js +611 -38
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +612 -34
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -77,7 +77,10 @@ Or use the ready-made screen:
|
|
|
77
77
|
authenticatedRedirect="/" // where to send someone who already has a session
|
|
78
78
|
onCodeSent={email => notify(`Code sent to ${email}`)}
|
|
79
79
|
onSuccess={(user, { result, redirectHandled }) => notify(`Welcome ${user?.email}`)}
|
|
80
|
-
onError={
|
|
80
|
+
onError={(error, { isShownOnCard }) => {
|
|
81
|
+
// A wrong, expired or exhausted code is already explained on the card
|
|
82
|
+
if (!isShownOnCard) notify(error.message) // error.code carries the stable identifier
|
|
83
|
+
}}
|
|
81
84
|
/>
|
|
82
85
|
```
|
|
83
86
|
|
|
@@ -87,6 +90,10 @@ Or use the ready-made screen:
|
|
|
87
90
|
`redirectOrigins` adds domains and `handleRedirect={false}` hands control back to the app.
|
|
88
91
|
- A wrong code fails with `error.details.attemptsLeft`. Five wrong tries destroy the request and
|
|
89
92
|
the person asks for a new code.
|
|
93
|
+
- On the code step the card explains every failure itself: how many tries are left, or, once the
|
|
94
|
+
code is exhausted or expired, a button that sends a new one. `onError` still fires, with a second
|
|
95
|
+
argument `{ step: 'request' | 'verify', isShownOnCard }`; skip your own notification when
|
|
96
|
+
`isShownOnCard` is `true`, or the person reads the same failure twice.
|
|
90
97
|
|
|
91
98
|
### Social sign-in
|
|
92
99
|
|
|
@@ -104,6 +111,29 @@ reads the token the callback leaves in the URL fragment — `AuthProvider` alrea
|
|
|
104
111
|
for you. `startSocialLink()`, `unlinkSocialProvider()` and `getLinkedProviders()` manage the
|
|
105
112
|
connections of an account that is already signed in.
|
|
106
113
|
|
|
114
|
+
### Recent accounts
|
|
115
|
+
|
|
116
|
+
`<SignIn />` remembers the accounts that signed in on this browser and, on the next visit, shows
|
|
117
|
+
them before the email field. One click on an account sends the code (or goes back to the provider
|
|
118
|
+
that account used last time) and opens the code step. With nothing saved, the screen is the plain
|
|
119
|
+
email form.
|
|
120
|
+
|
|
121
|
+
- An account is saved only after a session exists: the code confirmed, or the provider's token
|
|
122
|
+
back. A mistyped email never becomes a suggestion.
|
|
123
|
+
- The list keeps the five most recent accounts. Each entry holds the email, the way in and the
|
|
124
|
+
time of the last sign-in. It lives in `localStorage` under `auth:recent-accounts`, so each
|
|
125
|
+
origin keeps its own list.
|
|
126
|
+
- Signing out keeps the list. "Gerenciar" on the screen removes an account; nothing else about
|
|
127
|
+
that account changes.
|
|
128
|
+
|
|
129
|
+
```jsx
|
|
130
|
+
<SignIn /> {/* shows and saves recent accounts */}
|
|
131
|
+
<SignIn recentAccounts={false} /> {/* shared computers: neither shows nor saves */}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Building your own screen? `listRecentAccounts()`, `rememberAccount(email, method)` and
|
|
135
|
+
`forgetAccount(email)` read and write the same list.
|
|
136
|
+
|
|
107
137
|
## API
|
|
108
138
|
|
|
109
139
|
### Components
|