This commit is contained in:
2025-12-08 16:39:47 +08:00
parent 0a1c30f669
commit fd8c08316b
30 changed files with 306 additions and 85 deletions

View File

@@ -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;

View File

@@ -10,6 +10,7 @@
NS_ASSUME_NONNULL_BEGIN
@interface KBForgetPwdNewPwdVC : BaseViewController
@property (nonatomic, copy) NSString *email;
@end

View File

@@ -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

View File

@@ -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];

View File

@@ -10,6 +10,7 @@
NS_ASSUME_NONNULL_BEGIN
@interface KBForgetVerPwdVC : BaseViewController
@property (nonatomic, copy) NSString *email;
@end

View File

@@ -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

View File

@@ -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;