@@ -160,12 +160,24 @@ In the Ory Console go to <ConsoleLink route="project.mfa" />
160
160
### Account recovery address
161
161
162
162
To start account recovery, Ory Identities must know which address to send the recovery message to. Usually this is the email
163
- address the user provides when registering their account. Other fields inside the ` traits ` section are supported as well.
163
+ address the user provides when registering their account. Other fields inside the ` traits ` section are supported as well such as
164
+ phone number to receive the code via an SMS.
165
+
166
+ If a user has multiple recovery addresses and the ` choose_recovery_address ` feature flag is
167
+ [ enabled] ( ../../../identities/get-started/account-recovery.mdx#enable-the-feature-flag-choose_recovery_address-unlocks-sending-a-recovery-code-via-sms ) ,
168
+ the process is as follows:
169
+
170
+ 1 . The user enters any of their registered addresses to begin the recovery flow.
171
+ 1 . A masked list of their recovery addresses is displayed. Up to 10 addresses are shown.
172
+ 1 . After selecting an address, the user must enter it in full. This step verifies ownership and helps prevent information leaks.
173
+ 1 . The recovery message is sent to the confirmed address via email or SMS.
174
+
175
+ A [ SMS HTTP gateway] ( ../../emails-sms/10_sending-sms.mdx ) must be configured to deliver SMS messages.
164
176
165
177
:::info
166
178
167
- If the email address used for recovery is the same as the email used for verification and the account isn't activated when the
168
- recovery flow is started, completing the recovery flow also verifies the user's email address.
179
+ If the address used for recovery is the same as the address used for verification and the account isn't activated when the
180
+ recovery flow is started, completing the recovery flow also verifies the user's address.
169
181
170
182
Read [ this document] ( ./verify-email-account-activation.mdx ) to learn about the account verification flow.
171
183
@@ -204,14 +216,79 @@ To specify a trait of the identity to be used for recovery, use the following id
204
216
}
205
217
```
206
218
219
+ Example to allow recovery via an email or an SMS:
220
+
221
+ ``` json
222
+ {
223
+ "$id" : " https://example.com/registration.schema.json" ,
224
+ "$schema" : " http://json-schema.org/draft-07/schema#" ,
225
+ "title" : " Person" ,
226
+ "type" : " object" ,
227
+ "properties" : {
228
+ "traits" : {
229
+ "type" : " object" ,
230
+ "properties" : {
231
+ "email" : {
232
+ "title" : " Email" ,
233
+ "type" : " string" ,
234
+ "format" : " email" ,
235
+ "ory.sh/kratos" : {
236
+ "credentials" : {
237
+ "password" : {
238
+ "identifier" : true
239
+ },
240
+ "code" : {
241
+ "identifier" : true ,
242
+ "via" : " email"
243
+ }
244
+ },
245
+ "recovery" : {
246
+ "via" : " email"
247
+ }
248
+ }
249
+ },
250
+ "telephoneNumber" : {
251
+ "type" : " string" ,
252
+ "format" : " tel" ,
253
+ "title" : " Telephone Number" ,
254
+ "minLength" : 3 ,
255
+ "ory.sh/kratos" : {
256
+ "credentials" : {
257
+ "password" : {
258
+ "identifier" : true
259
+ },
260
+ "code" : {
261
+ "identifier" : true ,
262
+ "via" : " sms"
263
+ }
264
+ },
265
+ "verification" : {
266
+ "via" : " sms"
267
+ },
268
+ "recovery" : {
269
+ "via" : " sms"
270
+ }
271
+ }
272
+ }
273
+ },
274
+ "required" : [" email" ],
275
+ "additionalProperties" : false
276
+ }
277
+ }
278
+ }
279
+ ```
280
+
207
281
### Attempted recovery notifications
208
282
209
283
When this option is on and users attempt to initiate recovery for unregistered addresses, the system sends an attempted recovery
210
284
notification to the email address that was used in the attempt. This prevents account enumeration attacks as explained in this
211
285
[ blog post by Troy Hunt] ( https://www.troyhunt.com/website-enumeration-insanity-how-our-personal-data-is-leaked/ ) . By default, this
212
286
feature is disabled in newly created Ory Network projects.
213
287
214
- Follow these steps to enable sending attempted recovery notifications:
288
+ For cost reasons, the attempted recovery notification does not apply to SMS. An attempt to recover an account using an incorrect
289
+ phone number will not trigger an SMS message.
290
+
291
+ Follow these steps to send attempted recovery notification emails:
215
292
216
293
``` mdx-code-block
217
294
<Tabs groupId="console-or-cli">
@@ -260,12 +337,13 @@ Go to <ConsoleLink route="project.recovery" /> and toggle **Notify unknown recip
260
337
</Tabs>
261
338
```
262
339
263
- ### Email templates
340
+ ### Templates
264
341
265
- Ory Identities comes with default email templates for recovery flows.
342
+ Ory Identities comes with default templates for recovery flows.
266
343
267
344
You can replace the defaults and customize the messages to match the look and feel of your solution. Read the
268
- [ email templates documentation] ( ../../emails-sms/05_custom-email-templates.mdx ) to learn more.
345
+ [ email templates documentation] ( ../../emails-sms/05_custom-email-templates.mdx ) and
346
+ [ SMS templates documentation] ( ../../emails-sms/10_sending-sms.mdx#templates ) to learn more.
269
347
270
348
## Invalidate other sessions
271
349
@@ -324,11 +402,11 @@ Learn how to [add and configure hooks for self-service user flows](../../hooks/0
324
402
325
403
## Fallback recovery address
326
404
327
- In some scenarios, users may want to recover their account using a different email address than the one they used to register, for
328
- example if they no longer have access to the original email address. To use two (or more) recovery email addresses, you need to
329
- define a secondary email field, such as ` email_secondary ` in the traits section of the identity schema. This field will serve as
330
- the fallback email address for account recovery. Read more about identity schemas
331
- [ here ] ( ../../manage-identities/05_identity-schema.mdx ) .
405
+ A user may need a fallback recovery address if they lose access to the address used for registration.
406
+
407
+ To enable this, define a secondary field, such as email_secondary, in the traits section of your
408
+ [ identity schema ] ( ../../manage-identities/05_identity-schema.mdx ) . This field will serve as the alternative address for account
409
+ recovery .
332
410
333
411
This is an example of an identity schema with a secondary email address:
334
412
@@ -400,6 +478,10 @@ In this schema, you define both `email` and `email_secondary` fields as recovery
400
478
messages to both addresses when the recovery flow is initiated. The user should provide the ` email_secondary ` field during
401
479
registration or update it later in their account settings so it can be used in the recovery process.
402
480
481
+ This is different from the scenario where a user has multiple recovery addresses of different types, such as one email address and
482
+ one phone number. In that case, the user is prompted to choose which address to use, and a recovery message is sent to only the
483
+ one they select.
484
+
403
485
## Native recovery flows
404
486
405
487
Ory Identities supports recovery flows in native applications. This allows you to build a native application that allows the user
0 commit comments