Skip to content

Commit a9b1f1e

Browse files
committed
登录时,检查邮箱是否已激活
1 parent 0b6c0ab commit a9b1f1e

File tree

3 files changed

+27
-15
lines changed

3 files changed

+27
-15
lines changed

Coding_iOS/Controllers/Login/LoginViewController.m

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ - (void)sendLogin{
413413
if (data) {
414414
[Login setPreUserEmail:self.myLogin.email];//记住登录账号
415415
[((AppDelegate *)[UIApplication sharedApplication].delegate) setupTabViewController];
416+
[self doSomethingAfterLogin];
416417
}else{
417418
NSString *global_key = error.userInfo[@"msg"][@"two_factor_auth_code_not_empty"];
418419
if (global_key.length > 0) {
@@ -430,6 +431,29 @@ - (void)sendLogin{
430431
}
431432
}
432433

434+
- (void)doSomethingAfterLogin{
435+
User *curUser = [Login curLoginUser];
436+
if (curUser.email.length > 0 && !curUser.email_validation.boolValue) {
437+
UIAlertView *alertView = [UIAlertView bk_alertViewWithTitle:@"激活邮箱" message:@"该邮箱尚未激活,请尽快去邮箱查收邮件并激活账号。如果在收件箱中没有看到,请留意一下垃圾邮件箱子(T_T)"];
438+
[alertView bk_setCancelButtonWithTitle:@"取消" handler:nil];
439+
[alertView bk_addButtonWithTitle:@"重发激活邮件" handler:nil];
440+
[alertView bk_setDidDismissBlock:^(UIAlertView *alert, NSInteger index) {
441+
if (index == 1) {
442+
[self sendActivateEmail];
443+
}
444+
}];
445+
[alertView show];
446+
447+
}
448+
}
449+
- (void)sendActivateEmail{
450+
[[Coding_NetAPIManager sharedManager] request_SendActivateEmail:[Login curLoginUser].email block:^(id data, NSError *error) {
451+
if (data) {
452+
[NSObject showHudTipStr:@"邮件已发送"];
453+
}
454+
}];
455+
}
456+
433457
- (IBAction)cannotLoginBtnClicked:(id)sender {
434458
CannotLoginViewController *vc = [CannotLoginViewController vcWithMethodType:0 stepIndex:0 userStr:(([self.myLogin.email isPhoneNo] || [self.myLogin.email isEmail])? self.myLogin.email: nil)];
435459
[self.navigationController pushViewController:vc animated:YES];

Coding_iOS/Controllers/MeSetting/SettingAccountViewController.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
7878
if (self.myUser.email_validation.boolValue || self.myUser.email.length <= 0) {
7979
TitleValueCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_TitleValue forIndexPath:indexPath];
8080
cell.selectionStyle = UITableViewCellSelectionStyleNone;
81-
[cell setTitleStr:@"邮箱" valueStr:self.myUser.email ?: @"未绑定"];
81+
[cell setTitleStr:@"邮箱" valueStr:self.myUser.email.length > 0 ? self.myUser.email: @"未绑定"];
8282
[tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:kPaddingLeftWidth];
8383
return cell;
8484
}else{
@@ -89,7 +89,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
8989
}
9090
}else{
9191
TitleValueMoreCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_TitleValueMore forIndexPath:indexPath];
92-
[cell setTitleStr:@"手机号码" valueStr:self.myUser.phone ?: @"未绑定"];
92+
[cell setTitleStr:@"手机号码" valueStr:self.myUser.phone.length > 0 ? self.myUser.phone: @"未绑定"];
9393
[tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:kPaddingLeftWidth];
9494
return cell;
9595
}

Coding_iOS/Models/Login.m

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,12 @@ - (instancetype)init
3030
}
3131

3232
- (NSString *)toPath{
33-
NSString *path = @"https://coding.net/api/v2/account/login";
34-
// if ([self.email isPhoneNo]) {
35-
// path = @"api/account/login/phone";
36-
// }else{
37-
// path = @"api/login";
38-
// }
39-
return path;
33+
return @"https://coding.net/api/v2/account/login";
4034
}
4135
- (NSDictionary *)toParams{
4236
NSMutableDictionary *params = @{@"account": self.email,
4337
@"password" : [self.password sha1Str],
4438
@"remember_me" : self.remember_me? @"true" : @"false",}.mutableCopy;
45-
// if ([self.email isPhoneNo]) {
46-
// params[@"phone"] = self.email;
47-
// }else{
48-
// params[@"email"] = self.email;
49-
// }
5039
if (self.j_captcha.length > 0) {
5140
params[@"j_captcha"] = self.j_captcha;
5241
}
@@ -86,7 +75,6 @@ + (void)doLogin:(NSDictionary *)loginData{
8675
// NSLog(@"cookies : %@", obj.description);
8776
// }];
8877

89-
9078
if (loginData) {
9179
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
9280
[defaults setObject:[NSNumber numberWithBool:YES] forKey:kLoginStatus];

0 commit comments

Comments
 (0)