Skip to content

Commit a7cae20

Browse files
authored
chore(docs): add swift example for user update with nonce (supabase#27925)
chore(docs): add examle for user update with nonce
1 parent 0624e3a commit a7cae20

File tree

1 file changed

+78
-2
lines changed

1 file changed

+78
-2
lines changed

apps/docs/spec/supabase_swift_v2.yml

Lines changed: 78 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ functions:
7373
title: "Overview"
7474
notes: |
7575
The auth methods can be accessed via the `supabase.auth` namespace.
76-
76+
7777
### Handling deep links
7878
7979
#### UIKit app lifecycle
@@ -120,7 +120,7 @@ functions:
120120
supabase.auth.handle(url)
121121
}
122122
```
123-
123+
124124
examples:
125125
- id: create-auth-client
126126
name: Create auth client
@@ -767,6 +767,68 @@ functions:
767767
```swift
768768
try await supabase.auth.update(user: UserAttributes(email: "new@email.com"))
769769
```
770+
response: |
771+
```json
772+
{
773+
"user": {
774+
"id": "11111111-1111-1111-1111-111111111111",
775+
"aud": "authenticated",
776+
"role": "authenticated",
777+
"email": "example@email.com",
778+
"email_confirmed_at": "2024-01-01T00:00:00Z",
779+
"phone": "",
780+
"confirmed_at": "2024-01-01T00:00:00Z",
781+
"new_email": "new@email.com",
782+
"email_change_sent_at": "2024-01-01T00:00:00Z",
783+
"last_sign_in_at": "2024-01-01T00:00:00Z",
784+
"app_metadata": {
785+
"provider": "email",
786+
"providers": [
787+
"email"
788+
]
789+
},
790+
"user_metadata": {
791+
"email": "example@email.com",
792+
"email_verified": false,
793+
"phone_verified": false,
794+
"sub": "11111111-1111-1111-1111-111111111111"
795+
},
796+
"identities": [
797+
{
798+
"identity_id": "22222222-2222-2222-2222-222222222222",
799+
"id": "11111111-1111-1111-1111-111111111111",
800+
"user_id": "11111111-1111-1111-1111-111111111111",
801+
"identity_data": {
802+
"email": "example@email.com",
803+
"email_verified": false,
804+
"phone_verified": false,
805+
"sub": "11111111-1111-1111-1111-111111111111"
806+
},
807+
"provider": "email",
808+
"last_sign_in_at": "2024-01-01T00:00:00Z",
809+
"created_at": "2024-01-01T00:00:00Z",
810+
"updated_at": "2024-01-01T00:00:00Z",
811+
"email": "example@email.com"
812+
}
813+
],
814+
"created_at": "2024-01-01T00:00:00Z",
815+
"updated_at": "2024-01-01T00:00:00Z",
816+
"is_anonymous": false
817+
}
818+
}
819+
```
820+
- id: update-the-phone-for-an-authenticated-user
821+
name: Update the phone number for an authenticated user
822+
description: Sends a one-time password (OTP) to the new phone number.
823+
isSpotlight: false
824+
code: |
825+
```swift
826+
try await supabase.auth.update(
827+
user: UserAttributes(
828+
phone: "123456789"
829+
)
830+
)
831+
```
770832
- id: update-the-password-for-an-authenticated-user
771833
name: Update the password for an authenticated user
772834
isSpotlight: false
@@ -787,6 +849,20 @@ functions:
787849
)
788850
)
789851
```
852+
- id: update-password-with-reauthentication
853+
name: Update the user's password with a nonce
854+
description: |
855+
If **Secure password change** is enabled in your [project's email provider settings](/dashboard/project/_/auth/providers), updating the user's password would require a nonce if the user **hasn't recently signed in**. The nonce is sent to the user's email or phone number. A user is deemed recently signed in if the session was created in the last 24 hours.
856+
isSpotlight: true
857+
code: |
858+
```swift
859+
try await supabase.auth.update(
860+
user: UserAttributes(
861+
password: "new password",
862+
nonce: "123456"
863+
)
864+
)
865+
```
790866
- id: get-user-identities
791867
title: "userIdentities()"
792868
notes: |

0 commit comments

Comments
 (0)