3
This commit is contained in:
32
keyBoard/Class/Login/VM/KBLoginVM.h
Normal file
32
keyBoard/Class/Login/VM/KBLoginVM.h
Normal file
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// 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);
|
||||
|
||||
@interface KBLoginVM : NSObject
|
||||
|
||||
+ (instancetype)shared;
|
||||
|
||||
/// 最近一次登录/拉取到的用户信息(仅内存缓存),可选
|
||||
@property (atomic, strong, readonly, nullable) KBUser *currentUser; // 最近一次解析得到的用户
|
||||
|
||||
/// 调起 Apple 登录并在服务端完成校验;成功后会将 token 写入共享钥匙串(KBAuthManager),作为“已登录”的判断依据。
|
||||
- (void)signInWithAppleFromViewController:(UIViewController *)presenter
|
||||
completion:(KBLoginCompletion)completion;
|
||||
|
||||
/// 是否已登录:由 KBAuthManager 判断(是否存在有效 token)
|
||||
- (BOOL)isLoggedIn;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
Reference in New Issue
Block a user