-
-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(docs): add password recovery example (#548)
- Loading branch information
Showing
11 changed files
with
120 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// | ||
// ResetPasswordView.swift | ||
// Examples | ||
// | ||
// Created by Guilherme Souza on 30/09/24. | ||
// | ||
|
||
import SwiftUI | ||
import SwiftUINavigation | ||
|
||
struct ResetPasswordView: View { | ||
@State private var email: String = "" | ||
@State private var showAlert = false | ||
@State private var alertMessage = "" | ||
|
||
var body: some View { | ||
VStack(spacing: 20) { | ||
Text("Reset Password") | ||
.font(.largeTitle) | ||
.fontWeight(.bold) | ||
|
||
TextField("Enter your email", text: $email) | ||
.textFieldStyle(RoundedBorderTextFieldStyle()) | ||
.autocapitalization(.none) | ||
.keyboardType(.emailAddress) | ||
|
||
Button(action: resetPassword) { | ||
Text("Send Reset Link") | ||
.foregroundColor(.white) | ||
.padding() | ||
.background(Color.blue) | ||
.cornerRadius(10) | ||
} | ||
} | ||
.padding() | ||
.alert("Password reset", isPresented: $showAlert, actions: {}, message: { | ||
Text(alertMessage) | ||
}) | ||
} | ||
|
||
func resetPassword() { | ||
Task { | ||
do { | ||
try await supabase.auth.resetPasswordForEmail(email) | ||
alertMessage = "Password reset email sent successfully" | ||
} catch { | ||
alertMessage = "Error sending password reset email: \(error.localizedDescription)" | ||
} | ||
showAlert = true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters