punchnet-macos/punchnet/Features/Auth/ViewModels/ResetPasswordModel.swift
2026-04-17 16:47:57 +08:00

42 lines
1.1 KiB
Swift

//
// LoginState.swift
// punchnet
//
// Created by on 2026/1/16.
//
import Foundation
import Observation
import SwiftUI
@Observable
class ResetPasswordModel {
enum Stage: Equatable {
case requestVerifyCode
case submitVerifyCode
case resetPassword
case success
}
var stage: Stage = .requestVerifyCode
var transitionEdge: Edge = .trailing //
//
var phoneNumber: String = ""
var sessionId: Int = 0
func requestVerifyCode(phoneNumber: String) async throws -> AuthService.ResetPasswordSession {
return try await AuthService.requestResetPasswordVerifyCode(phoneNumber: phoneNumber)
}
func submitVerifyCode(sessionId: Int, verifyCode: String) async throws -> String {
return try await AuthService.submitResetPasswordVerifyCode(sessionId: sessionId, verifyCode: verifyCode)
}
func resetPassword(sessionId: Int, newPassword: String) async throws -> String {
return try await AuthService.resetPassword(sessionId: sessionId, newPassword: newPassword)
}
}