1
This commit is contained in:
@@ -138,6 +138,8 @@
|
||||
}];
|
||||
|
||||
[self.emailFieldContainer addSubview:self.emailTextField];
|
||||
NSString *email = [[NSUserDefaults standardUserDefaults] objectForKey:KBUserEmailKey];
|
||||
self.emailTextField.text = email;
|
||||
[self.emailTextField mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.equalTo(self.emailFieldContainer).insets(UIEdgeInsetsMake(0, 16, 0, 16));
|
||||
}];
|
||||
@@ -229,6 +231,8 @@
|
||||
|
||||
[self.loginVM emailLoginEmail:email password:password WithCompletion:^(BOOL success, NSError * _Nullable error) {
|
||||
if (success) {
|
||||
[[NSUserDefaults standardUserDefaults] setValue:email forKey:KBUserEmailKey];
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
id<UIApplicationDelegate> appDelegate = UIApplication.sharedApplication.delegate;
|
||||
if ([appDelegate respondsToSelector:@selector(setupRootVC)]) {
|
||||
AppDelegate *delegate = (AppDelegate *)appDelegate;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface KBForgetPwdNewPwdVC : BaseViewController
|
||||
@property (nonatomic, copy) NSString *email;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
//
|
||||
|
||||
#import "KBForgetPwdNewPwdVC.h"
|
||||
|
||||
#import "KBLoginVM.h"
|
||||
#import "KBEmailRegistVC.h"
|
||||
@interface KBForgetPwdNewPwdVC () <UITextFieldDelegate>
|
||||
|
||||
@property (nonatomic, strong) UILabel *titleLabel; // Reset Password
|
||||
@@ -124,6 +125,25 @@
|
||||
|
||||
KBLOG(@"KBForgetPwdNewPwdVC next step, pwdLen=%zd", pwd.length);
|
||||
// TODO: 提交新密码逻辑
|
||||
NSString *rEmail = self.email ? self.email : @"";
|
||||
[[KBLoginVM shared] resetPassWord:rEmail password:pwd confirmPassword:pwd withCompletion:^(BOOL success, NSError * _Nullable error) {
|
||||
/// 成功后删除栈内忘记密码的页面
|
||||
if (success) {
|
||||
UIViewController *targetVC = nil;
|
||||
for (UIViewController *vc in KB_CURRENT_NAV.viewControllers) {
|
||||
if ([vc isKindOfClass:[KBEmailRegistVC class]]) {
|
||||
targetVC = vc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (targetVC) {
|
||||
[KB_CURRENT_NAV popToViewController:targetVC animated:YES];
|
||||
} else {
|
||||
// 如果没找到,可以选择 popToRootViewController 或自定义逻辑
|
||||
[KB_CURRENT_NAV popToRootViewControllerAnimated:YES];
|
||||
}
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - UITextFieldDelegate
|
||||
|
||||
@@ -73,6 +73,7 @@
|
||||
KBLOG(@"KBForgetPwdVC next step with email=%@", email);
|
||||
// TODO: 接 forgot password 接口
|
||||
KBForgetVerPwdVC *vc = [[KBForgetVerPwdVC alloc] init];
|
||||
vc.email = email;
|
||||
UINavigationController *nav = KB_CURRENT_NAV;
|
||||
if ([nav isKindOfClass:[BaseNavigationController class]]) {
|
||||
[(BaseNavigationController *)nav kb_pushViewControllerRemovingSameClass:vc animated:YES];
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface KBForgetVerPwdVC : BaseViewController
|
||||
@property (nonatomic, copy) NSString *email;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -27,6 +27,12 @@
|
||||
[self kb_addTapToDismissKeyboard];
|
||||
|
||||
[self setupUI];
|
||||
NSString *reEmail = self.email ? self.email : @"";
|
||||
[[KBLoginVM shared] sendVerifyMailWithEmail:reEmail withCompletion:^(BOOL success, NSError * _Nullable error) {
|
||||
if (success) {
|
||||
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - UI
|
||||
@@ -75,14 +81,20 @@
|
||||
return;
|
||||
}
|
||||
KBLOG(@"KBVerPwdVC next step with code=%@", code);
|
||||
// TODO: 接后续重置密码的下一步逻辑
|
||||
KBForgetPwdNewPwdVC *vc = [[KBForgetPwdNewPwdVC alloc] init];
|
||||
UINavigationController *nav = KB_CURRENT_NAV;
|
||||
if ([nav isKindOfClass:[BaseNavigationController class]]) {
|
||||
[(BaseNavigationController *)nav kb_pushViewControllerRemovingSameClass:vc animated:YES];
|
||||
} else {
|
||||
[nav pushViewController:vc animated:YES];
|
||||
}
|
||||
[[KBLoginVM shared] verifyEMailCode:self.email verifyCode:code withCompletion:^(BOOL success, NSError * _Nullable error) {
|
||||
if (success) {
|
||||
KBForgetPwdNewPwdVC *vc = [[KBForgetPwdNewPwdVC alloc] init];
|
||||
vc.email = self.email;
|
||||
UINavigationController *nav = KB_CURRENT_NAV;
|
||||
if ([nav isKindOfClass:[BaseNavigationController class]]) {
|
||||
[(BaseNavigationController *)nav kb_pushViewControllerRemovingSameClass:vc animated:YES];
|
||||
} else {
|
||||
[nav pushViewController:vc animated:YES];
|
||||
}
|
||||
}
|
||||
}];
|
||||
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - Lazy UI
|
||||
|
||||
@@ -99,11 +99,14 @@
|
||||
if (genderNumber != nil) {
|
||||
self.params[@"gender"] = genderNumber;
|
||||
}
|
||||
NSString *email = self.params[@"mailAddress"] ? self.params[@"mailAddress"] : @"";
|
||||
[self.loginVM emailRegisterParams:self.params withCompletion:^(BOOL success, NSError * _Nullable error) {
|
||||
if (success) {
|
||||
[KBHUD showInfo:KBLocalized(@"Signed in successfully")];
|
||||
// 登录成功后切换到主 TabBar
|
||||
//注册成功后切换到主 TabBar
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[[NSUserDefaults standardUserDefaults] setValue:email forKey:KBUserEmailKey];
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
KBEmailLoginVC *vc = [[KBEmailLoginVC alloc] init];
|
||||
[KB_CURRENT_NAV pushViewController:vc animated:true];
|
||||
// id<UIApplicationDelegate> appDelegate = UIApplication.sharedApplication.delegate;
|
||||
|
||||
Reference in New Issue
Block a user