1
This commit is contained in:
@@ -100,12 +100,35 @@
|
||||
}
|
||||
[[KBUserSessionManager shared] handleLoginSuccessWithUser:user];
|
||||
completion(true,nil);
|
||||
// 保存登录态到共享钥匙串;供 App 与扩展共享
|
||||
// BOOL ok = [[KBAuthManager shared] saveAccessToken:user.token
|
||||
// refreshToken:nil
|
||||
// expiryDate:nil
|
||||
// userIdentifier:cred.user];
|
||||
// if (completion) completion(ok, ok ? nil : [NSError errorWithDomain:@"KBLogin" code:-3 userInfo:@{NSLocalizedDescriptionKey: KBLocalized(@"Failed to save login state")}]);
|
||||
}];
|
||||
}
|
||||
|
||||
/// 邮箱注册
|
||||
- (void)emailRegisterParams:(NSDictionary *)params withCompletion:(KBRegisterCompletion)completion{
|
||||
[KBHUD show];
|
||||
// NSMutableDictionary *params = [NSMutableDictionary dictionary];
|
||||
// if (mailAddress.length) params[@"mailAddress"] = mailAddress;
|
||||
// if (password.length) params[@"password"] = password;
|
||||
// if (passwordConfirm.length) params[@"passwordConfirm"] = passwordConfirm;
|
||||
//
|
||||
// // 如有本地缓存的性别(首次进入首页时选择),一并上传给后端
|
||||
// NSNumber *genderNumber = [self kb_localGenderParamIfAvailable];
|
||||
// if (genderNumber != nil) {
|
||||
// params[@"gender"] = genderNumber;
|
||||
// }
|
||||
// 向服务端发起校验
|
||||
[[KBNetworkManager shared] POST:API_EMAIL_REGISTER jsonBody:params headers:nil completion:^(NSDictionary * _Nullable jsonOrData, NSURLResponse * _Nullable response, NSError * _Nullable error) {
|
||||
[KBHUD dismiss];
|
||||
if (error) { if (completion) completion(NO, error); return; }
|
||||
NSDictionary *dict = jsonOrData[@"data"];
|
||||
KBUser *user = [KBUser mj_objectWithKeyValues:dict];
|
||||
self.currentUser = user;
|
||||
if (user.token.length == 0) {
|
||||
if (completion) completion(NO, [NSError errorWithDomain:@"KBLogin" code:-2 userInfo:@{NSLocalizedDescriptionKey: KBLocalized(@"No token returned")}]);
|
||||
return;
|
||||
}
|
||||
[[KBUserSessionManager shared] handleLoginSuccessWithUser:user];
|
||||
completion(true,nil);
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user