Skip to content

Commit bcb4de4

Browse files
committed
Submit new password in ModifyPasswordViewController.
1 parent b74370d commit bcb4de4

File tree

9 files changed

+113
-37
lines changed

9 files changed

+113
-37
lines changed

Rate-iOS/Base.lproj/Main.storyboard

Lines changed: 62 additions & 35 deletions
Large diffs are not rendered by default.

Rate-iOS/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<key>CFBundlePackageType</key>
1818
<string>APPL</string>
1919
<key>CFBundleShortVersionString</key>
20-
<string>1.2</string>
20+
<string>1.2.1</string>
2121
<key>CFBundleSignature</key>
2222
<string>????</string>
2323
<key>CFBundleVersion</key>

Rate-iOS/InternetResponse.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ typedef NS_OPTIONS(NSUInteger, ErrorCode) {
1919
ErrorCodeNotValidated = 304,
2020
ErrorCodeMailNeedActivate = 330,
2121
ErrorCodeTokenError = 350,
22+
ErrorCodeMailNotExist = 360,
2223
ErrorCodeNotConnectedToInternet = -1009
2324
};
2425

Rate-iOS/PasswordViewController.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
@property (weak, nonatomic) IBOutlet UIButton *showPasswordButton;
2020
@property (weak, nonatomic) IBOutlet UIButton *sendButton;
2121
@property (weak, nonatomic) IBOutlet UIActivityIndicatorView *loadingActivityIndicatorView;
22+
@property (weak, nonatomic) IBOutlet UIView *modifySuccessView;
23+
@property (weak, nonatomic) IBOutlet UIButton *submitButton;
2224

2325
- (IBAction)showPassword:(id)sender;
2426
- (IBAction)sendVerificationCode:(id)sender;

Rate-iOS/PasswordViewController.m

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,15 @@ - (void)sendVerificationCode:(id)sender {
5656
if (_emailImageView.highlighted) {
5757
return;
5858
}
59+
_sendButton.enabled = NO;
5960
[manager POST:[InternetTool createUrl:@"api/user/verification_code"]
6061
parameters:@{@"email": _emailTextField.text}
6162
progress:nil
6263
success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
6364
InternetResponse *response = [[InternetResponse alloc] initWithResponseObject:responseObject];
6465
if ([response statusOK]) {
6566
_emailTextField.enabled = NO;
67+
_sendButton.enabled = YES;
6668
[AlertTool showAlertWithTitle:NSLocalizedString(@"tip_name", @"Tip")
6769
andContent:NSLocalizedString(@"send_validation_code_success", @"Verification code has sent to your email.")
6870
inViewController:self];
@@ -71,6 +73,11 @@ - (void)sendVerificationCode:(id)sender {
7173
failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
7274
InternetResponse *response = [[InternetResponse alloc] initWithError:error];
7375
switch ([response errorCode]) {
76+
case ErrorCodeMailNotExist:
77+
[AlertTool showAlertWithTitle:NSLocalizedString(@"tip_name", @"tip")
78+
andContent:NSLocalizedString(@"mail_not_exsit", @"The email you input is not exist.")
79+
inViewController:self];
80+
break;
7481
default:
7582
break;
7683
}
@@ -83,8 +90,37 @@ - (IBAction)submitNewPassword:(id)sender {
8390
}
8491
_verificationCodeImageView.highlighted = [_verificationCodeTextField.text isEqualToString:@""];
8592
_passwordImageView.highlighted = [_passwordTextField.text isEqualToString:@""];
86-
if (_emailImageView.highlighted && _passwordImageView.highlighted) {
93+
if (_verificationCodeImageView.highlighted || _passwordImageView.highlighted) {
8794
return;
8895
}
96+
[_loadingActivityIndicatorView startAnimating];
97+
[manager POST:[InternetTool createUrl:@"api/user/change_password"]
98+
parameters:@{
99+
@"email": _emailTextField.text,
100+
@"password": _passwordTextField.text,
101+
@"vertificationCode": _verificationCodeTextField.text
102+
}
103+
progress:nil
104+
success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
105+
InternetResponse *repsonse = [[InternetResponse alloc] initWithResponseObject:responseObject];
106+
if ([repsonse statusOK]) {
107+
//Modified password scuessfully.
108+
_modifySuccessView.hidden = NO;
109+
[_submitButton removeFromSuperview];
110+
[_loadingActivityIndicatorView stopAnimating];
111+
}
112+
}
113+
failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
114+
InternetResponse *response = [[InternetResponse alloc] initWithError:error];
115+
switch ([response errorCode]) {
116+
case ErrorCodeMailNotExist:
117+
[AlertTool showAlertWithTitle:NSLocalizedString(@"tip_name", @"tip")
118+
andContent:NSLocalizedString(@"mail_not_exsit", @"The email you input is not exist.")
119+
inViewController:self];
120+
break;
121+
default:
122+
break;
123+
}
124+
}];
89125
}
90126
@end

Rate-iOS/en.lproj/Localizable.strings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,4 @@ share_news = "Share News";
5555
open_on_safari = "Open on Safari";
5656

5757
send_validation_code_success = "Verification code has sent to your email.";
58+
mail_not_exsit = "This email is not registered.";

Rate-iOS/en.lproj/Main.strings

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,3 +478,7 @@
478478

479479
/* Class = "UIButton"; normalTitle = "Send"; ObjectID = "h2M-Yk-uDf"; */
480480
"h2M-Yk-uDf.normalTitle" = "Send";
481+
//#Generate strings in 2016-12-04 19:52:34
482+
483+
/* Class = "UILabel"; text = "Register Success !"; ObjectID = "oyh-AD-3IS"; */
484+
"oyh-AD-3IS.text" = "Register Success !";

Rate-iOS/zh-Hans-CN.lproj/Localizable.strings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,4 @@ share_news = "分享新闻";
5353
open_on_safari = "在Safari中打开";
5454

5555
send_validation_code_success = "验证码已发送到您的邮箱,请注意查收。";
56+
mail_not_exsit = "该邮箱未注册。";

Rate-iOS/zh-Hans-CN.lproj/Main.strings

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,3 +363,7 @@
363363

364364
/* Class = "UIButton"; normalTitle = "Send"; ObjectID = "h2M-Yk-uDf"; */
365365
"h2M-Yk-uDf.normalTitle" = "发送";
366+
//#Generate strings in 2016-12-04 19:52:34
367+
368+
/* Class = "UILabel"; text = "Register Success !"; ObjectID = "oyh-AD-3IS"; */
369+
"oyh-AD-3IS.text" = "密码更改成功!";

0 commit comments

Comments
 (0)