1
This commit is contained in:
@@ -91,7 +91,7 @@
|
||||
{
|
||||
[KBHUD show];
|
||||
NSMutableDictionary *params = [NSMutableDictionary dictionary];
|
||||
if (email.length) params[@"email"] = email;
|
||||
if (email.length) params[@"mail"] = email;
|
||||
if (password.length) params[@"password"] = password;
|
||||
// 如有本地缓存的性别(首次进入首页时选择),一并上传给后端
|
||||
NSNumber *genderNumber = [self kb_localGenderParamIfAvailable];
|
||||
@@ -132,15 +132,6 @@
|
||||
[[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];
|
||||
[KBLoginVM kb_configureIAPIfNeeded];
|
||||
if (completion) completion(YES, nil);
|
||||
}];
|
||||
}
|
||||
@@ -149,16 +140,38 @@
|
||||
- (void)sendVerifyMailWithEmail:(NSString *)email withCompletion:(KBVerifyMailCompletion)completion{
|
||||
NSMutableDictionary *params = [NSMutableDictionary dictionary];
|
||||
if (email.length) params[@"mailAddress"] = email;
|
||||
// [[KBNetworkManager shared] POST:API_EMAIL_REGISTER jsonBody:params headers:nil completion:^(NSDictionary * _Nullable jsonOrData, NSURLResponse * _Nullable response, NSError * _Nullable error) {
|
||||
// if (error) { if (completion) completion(NO, error); return; }
|
||||
// [];
|
||||
// completion(true,nil);
|
||||
// }];
|
||||
[[KBNetworkManager shared] POST:API_EMAIL_REGISTER jsonBody:params headers:nil autoShowBusinessError:true completion:^(NSDictionary * _Nullable json, NSURLResponse * _Nullable response, NSError * _Nullable error) {
|
||||
[[KBNetworkManager shared] POST:API_SEND_EMAIL_VERIFYMAIL jsonBody:params headers:nil autoShowBusinessError:true completion:^(NSDictionary * _Nullable json, NSURLResponse * _Nullable response, NSError * _Nullable error) {
|
||||
|
||||
}];
|
||||
}
|
||||
|
||||
/// 验证验证码
|
||||
- (void)verifyEMailCode:(NSString *)email verifyCode:(NSString *)verifyCode withCompletion:(KBVerifyMailCompletion)completion{
|
||||
NSMutableDictionary *params = [NSMutableDictionary dictionary];
|
||||
if (email.length){
|
||||
params[@"mailAddress"] = email;
|
||||
params[@"verifyCode"] = verifyCode;
|
||||
|
||||
}
|
||||
[[KBNetworkManager shared] POST:API_VERIFY_EMAIL_CODE jsonBody:params headers:nil autoShowBusinessError:true completion:^(NSDictionary * _Nullable json, NSURLResponse * _Nullable response, NSError * _Nullable error) {
|
||||
if (error) { if (completion) completion(NO, error); return; }
|
||||
if (completion) completion(YES, nil);
|
||||
}];
|
||||
|
||||
}
|
||||
/// 重置密码
|
||||
- (void)resetPassWord:(NSString *)email password:(NSString *)password confirmPassword:(NSString *)confirmPassword withCompletion:(KBVerifyMailCompletion)completion;{
|
||||
NSMutableDictionary *params = [NSMutableDictionary dictionary];
|
||||
params[@"mailAddress"] = email ? email : @"";
|
||||
params[@"password"] = password ? password : @"";
|
||||
params[@"confirmPassword"] = confirmPassword;
|
||||
|
||||
[[KBNetworkManager shared] POST:API_RESET_PWD jsonBody:params headers:nil autoShowBusinessError:true completion:^(NSDictionary * _Nullable json, NSURLResponse * _Nullable response, NSError * _Nullable error) {
|
||||
if (error) { if (completion) completion(NO, error); return; }
|
||||
if (completion) completion(YES, nil);
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - Helpers
|
||||
|
||||
// 宽松解析:token / access_token / accessToken,支持顶层或 data/user 层
|
||||
|
||||
Reference in New Issue
Block a user