Skip to content

Commit ac16c03

Browse files
committed
πŸ› fix(auth): use correct API endpoint for password reset verification
Use sendResetPasswordCode and verifyResetPasswordCode endpoints instead of email verification endpoints during password reset flow.
1 parent 0f0fb4e commit ac16c03

File tree

5 files changed

+19
-3
lines changed

5 files changed

+19
-3
lines changed

β€ŽSNUTT/Modules/Feature/Auth/Sources/Infra/AuthAPIRepository.swiftβ€Ž

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,15 @@ extension AuthAPIRepository {
130130
_ = try result.ok.body.json
131131
}
132132

133+
public func sendResetPasswordCode(email: String) async throws {
134+
let result = try await apiClient.sendResetPasswordCode(body: .json(.init(email: email)))
135+
_ = try result.ok.body.json
136+
}
137+
133138
public func checkVerificationCode(localID: String, code: String) async throws {
134-
let result = try await apiClient.confirmEmailVerification(body: .json(.init(code: code)))
139+
let result = try await apiClient.verifyResetPasswordCode(
140+
body: .json(.init(code: code, user_id: localID))
141+
)
135142
_ = try result.ok.body.json
136143
}
137144

β€ŽSNUTT/Modules/Feature/Auth/Sources/Presentation/OnboardViewModel.swiftβ€Ž

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ final class OnboardViewModel {
6464
try await authRepository.sendVerificationCode(email: email)
6565
}
6666

67+
func sendResetPasswordCode(email: String) async throws {
68+
try await authRepository.sendResetPasswordCode(email: email)
69+
}
70+
6771
func checkVerificationCode(code: String, localID: String? = nil) async throws {
6872
if let localID {
6973
try await authRepository.checkVerificationCode(localID: localID, code: code)

β€ŽSNUTT/Modules/Feature/Auth/Sources/UI/ResetPasswordScene.swiftβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ struct ResetPasswordScene: View {
152152
focusedField = .email
153153
}
154154
} else {
155-
try await viewModel.sendVerificationCode(email: email)
155+
try await viewModel.sendResetPasswordCode(email: email)
156156
viewModel.paths.append(.verificationCode(email: email, mode: .resetPassword, localID: localID))
157157
}
158158
}

β€ŽSNUTT/Modules/Feature/Auth/Sources/UI/VerificationCodeScene.swiftβ€Ž

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,11 @@ struct VerificationCodeScene: View {
6060
initialRemainingTime: 180,
6161
onRestart: {
6262
errorAlertHandler.withAlert {
63-
try await viewModel.sendVerificationCode(email: email)
63+
if mode == .resetPassword {
64+
try await viewModel.sendResetPasswordCode(email: email)
65+
} else {
66+
try await viewModel.sendVerificationCode(email: email)
67+
}
6468
}
6569
},
6670
onTimeout: {

β€ŽSNUTT/Modules/Feature/AuthInterface/Sources/AuthRepository.swiftβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public protocol AuthRepository: Sendable {
3030
// Password reset & ID recovery
3131
func getLinkedEmail(localID: String) async throws -> String
3232
func sendVerificationCode(email: String) async throws
33+
func sendResetPasswordCode(email: String) async throws
3334
func checkVerificationCode(localID: String, code: String) async throws
3435
func resetPassword(localID: String, password: String, code: String) async throws
3536
func findLocalID(email: String) async throws

0 commit comments

Comments
Β (0)