2025-11-13 19:07:59 +08:00
|
|
|
|
//
|
|
|
|
|
|
// KBLoginVM.h
|
|
|
|
|
|
// 登录相关的 ViewModel:封装 Apple 登录与服务端校验、登录态落盘。
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
#import <Foundation/Foundation.h>
|
|
|
|
|
|
#import <UIKit/UIKit.h>
|
|
|
|
|
|
|
|
|
|
|
|
@class KBUser;
|
|
|
|
|
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
|
|
|
|
|
|
|
/// 登录完成回调
|
|
|
|
|
|
typedef void(^KBLoginCompletion)(BOOL success, NSError * _Nullable error);
|
2025-12-04 15:28:11 +08:00
|
|
|
|
typedef void(^KBRegisterCompletion)(BOOL success, NSError * _Nullable error);
|
2025-12-04 19:12:34 +08:00
|
|
|
|
typedef void(^KBVerifyMailCompletion)(BOOL success, NSError * _Nullable error);
|
2025-11-13 19:07:59 +08:00
|
|
|
|
|
|
|
|
|
|
@interface KBLoginVM : NSObject
|
|
|
|
|
|
|
|
|
|
|
|
+ (instancetype)shared;
|
|
|
|
|
|
|
|
|
|
|
|
/// 最近一次登录/拉取到的用户信息(仅内存缓存),可选
|
|
|
|
|
|
@property (atomic, strong, readonly, nullable) KBUser *currentUser; // 最近一次解析得到的用户
|
|
|
|
|
|
|
|
|
|
|
|
/// 调起 Apple 登录并在服务端完成校验;成功后会将 token 写入共享钥匙串(KBAuthManager),作为“已登录”的判断依据。
|
|
|
|
|
|
- (void)signInWithAppleFromViewController:(UIViewController *)presenter
|
|
|
|
|
|
completion:(KBLoginCompletion)completion;
|
|
|
|
|
|
|
2025-12-04 13:37:11 +08:00
|
|
|
|
|
|
|
|
|
|
/// 邮箱登录
|
|
|
|
|
|
- (void)emailLoginEmail:(NSString *)email password:(NSString *)password WithCompletion:(KBLoginCompletion)completion;
|
2025-12-04 15:28:11 +08:00
|
|
|
|
/// 邮箱注册
|
|
|
|
|
|
- (void)emailRegisterParams:(NSDictionary *)params withCompletion:(KBRegisterCompletion)completion;
|
2025-12-04 19:12:34 +08:00
|
|
|
|
/// 发送验证码
|
|
|
|
|
|
- (void)sendVerifyMailWithEmail:(NSString *)email withCompletion:(KBVerifyMailCompletion)completion;
|
2025-12-08 16:39:47 +08:00
|
|
|
|
/// 验证验证码
|
|
|
|
|
|
- (void)verifyEMailCode:(NSString *)email verifyCode:(NSString *)verifyCode withCompletion:(KBVerifyMailCompletion)completion;
|
|
|
|
|
|
/// 重置密码
|
|
|
|
|
|
- (void)resetPassWord:(NSString *)email password:(NSString *)password confirmPassword:(NSString *)confirmPassword withCompletion:(KBVerifyMailCompletion)completion;
|
2025-12-04 19:12:34 +08:00
|
|
|
|
|
2025-12-04 13:37:11 +08:00
|
|
|
|
|
2025-11-13 19:07:59 +08:00
|
|
|
|
/// 是否已登录:由 KBAuthManager 判断(是否存在有效 token)
|
|
|
|
|
|
- (BOOL)isLoggedIn;
|
|
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_END
|