Files
keyboard/Shared/KBUserSessionManager.h

45 lines
964 B
C
Raw Normal View History

2025-12-02 18:29:04 +08:00
//
// KBUserSessionManager.h
// keyBoard
//
// Created by Mac on 2025/12/1.
//
// KBUserSessionManager.h
// 主 App + 键盘扩展 共用的登录会话管理
#import <Foundation/Foundation.h>
@class KBUser;
NS_ASSUME_NONNULL_BEGIN
@interface KBUserSessionManager : NSObject
+ (instancetype)shared;
/// 当前登录用户(可能为 nil
@property (atomic, strong, readonly, nullable) KBUser *currentUser;
/// 是否已登录:由 KBAuthManager 基于 accessToken 判断
@property (nonatomic, assign, readonly) BOOL isLoggedIn;
/// 启动时调用:做“卸载重装”检测 & 恢复本地缓存
- (void)bootstrapIfNeeded;
/// 当前 accessToken可能为 nil/空字符串
- (nullable NSString *)accessToken;
/// 登录成功统一入口:写 Keychain + 缓存用户信息
- (void)handleLoginSuccessWithUser:(KBUser *)user;
/// 退出登录:清 Keychain + 本地缓存
- (void)logout;
2025-12-03 14:30:02 +08:00
- (void)goLoginVC;
2025-12-02 18:29:04 +08:00
@end
NS_ASSUME_NONNULL_END