[Bugfix][R305][bug-view-2070][login] add login username

Change-Id: I204a4e66e6242656167ed842d0e2eb11db3b6664
diff --git a/lynq/R305/ap/app/goahead/interface5.0/zte_web_mgmt.c b/lynq/R305/ap/app/goahead/interface5.0/zte_web_mgmt.c
index f0767ce..73af4c3 100755
--- a/lynq/R305/ap/app/goahead/interface5.0/zte_web_mgmt.c
+++ b/lynq/R305/ap/app/goahead/interface5.0/zte_web_mgmt.c
@@ -164,31 +164,6 @@
 		return;
 	}
 
-	if (user != NULL) {
-		slog(MISC_PRINT, SLOG_DEBUG," zte_mgmt_login  user = %s\n", user);
-		pUser = (char *)zte_base64_decode((const unsigned char *)user, strlen(user), (unsigned int*)&user_name_len);
-		if (NULL == pUser) {
-			zte_write_result_to_web(wp, LOGIN_FAIL);
-			return;
-		}
-
-		//strncpy(user_name, pUser, user_name_len);
-		if(user_name_len < sizeof(user_name))
-			snprintf(user_name,user_name_len+1,"%s",pUser);
-		else
-			snprintf(user_name,sizeof(user_name),"%s",pUser);
-		free(pUser);
-
-		slog(MISC_PRINT, SLOG_DEBUG," zte_mgmt_login  user_name = %s\n", user_name);
-		cfg_get_item("admin_user", buf, sizeof(buf));
-		if (0 != strcmp(user_name, buf)) {
-			slog(MISC_PRINT, SLOG_ERR," zte_mgmt_login user_name fail \n");
-			zte_write_result_to_web(wp, LOGIN_USER_NAME_NOT_EXSIT);
-			return;
-		}
-		slog(MISC_PRINT, SLOG_DEBUG," zte_mgmt_login uername correct \n");
-	}
-	slog(MISC_PRINT, SLOG_DEBUG,"[login] login1 -> zte_password_encode:%s.\n", psw); /*lint !e26*/
 #ifdef WEBS_SECURITY
 	zte_password = js_aes_decode(psw, strlen(psw), (unsigned int*)&zte_password_len);
 #else
@@ -217,6 +192,33 @@
 		return;
 	}
 
+	if (user != NULL) {
+		slog(MISC_PRINT, SLOG_DEBUG," zte_mgmt_login  user = %s\n", user);
+		pUser = (char *)zte_base64_decode((const unsigned char *)user, strlen(user), (unsigned int*)&user_name_len);
+		if (NULL == pUser) {
+			zte_write_result_to_web(wp, LOGIN_FAIL);
+			return;
+		}
+
+		//strncpy(user_name, pUser, user_name_len);
+		if(user_name_len < sizeof(user_name))
+			snprintf(user_name,user_name_len+1,"%s",pUser);
+		else
+			snprintf(user_name,sizeof(user_name),"%s",pUser);
+		free(pUser);
+
+		slog(MISC_PRINT, SLOG_DEBUG," zte_mgmt_login  user_name = %s\n", user_name);
+		cfg_get_item("admin_user", buf, sizeof(buf));
+		if (0 != strcmp(user_name, buf)) {
+			slog(MISC_PRINT, SLOG_ERR," zte_mgmt_login user_name fail \n");
+			zte_reduct_login_times();
+			zte_write_result_to_web(wp, LOGIN_USER_NAME_NOT_EXSIT);
+			return;
+		}
+		slog(MISC_PRINT, SLOG_DEBUG," zte_mgmt_login uername correct \n");
+	}
+	slog(MISC_PRINT, SLOG_DEBUG,"[login] login1 -> zte_password_encode:%s.\n", psw); /*lint !e26*/
+
 	//get request ip addr
 	ip_address = websGetRequestIpaddr(wp);
 #if 0 // kw 3	
diff --git a/lynq/R305/ap/app/zte_webui/i18n/Messages_en.properties b/lynq/R305/ap/app/zte_webui/i18n/Messages_en.properties
index 7fd8a9a..b0aa772 100755
--- a/lynq/R305/ap/app/zte_webui/i18n/Messages_en.properties
+++ b/lynq/R305/ap/app/zte_webui/i18n/Messages_en.properties
@@ -536,6 +536,7 @@
 sms_save_tip = Saving...

 

 #login

+username = Username

 password = Password

 puk = PUK

 login = Login

@@ -543,8 +544,8 @@
 new_pin = New PIN

 confirm_pin = Confirm New PIN

 puk_locked = Your SIM card is locked permanently. Please contact your operator.

-password_error = Password is incorrect!

-password_error_left = Password is incorrect!<br/>You have {0} attempt(s) left.

+password_error = Username or password is incorrect!

+password_error_left = Username or password is incorrect!<br/>You have {0} attempt(s) left.

 password_error_account_lock = Your account is locked. <br/>Remaining time:

 password_error_five_times = You''ve input 5 times incorrectly. Retry in 5 minutes.

 password_error_account_lock_time = Your account is locked. <br/>Please try later.

diff --git a/lynq/R305/ap/app/zte_webui/i18n/Messages_zh-cn.properties b/lynq/R305/ap/app/zte_webui/i18n/Messages_zh-cn.properties
index fc9c37a..4334a6c 100755
--- a/lynq/R305/ap/app/zte_webui/i18n/Messages_zh-cn.properties
+++ b/lynq/R305/ap/app/zte_webui/i18n/Messages_zh-cn.properties
@@ -538,6 +538,7 @@
 sms_save_tip = 保存草稿中...

 

 #login

+username = 用户名

 password = 密码

 puk = PUK

 login = 登录

@@ -545,8 +546,8 @@
 new_pin = 新 PIN

 confirm_pin = 确认新 PIN

 puk_locked = 您的 SIM卡已彻底锁定。请联系您的运营商。

-password_error = 密码不正确!

-password_error_left = 密码不正确!<br/>您的剩余尝试次数:{0}。

+password_error = 用户名或密码不正确!

+password_error_left = 用户名或密码不正确!<br/>您的剩余尝试次数:{0}。

 password_error_account_lock = 你的账户被锁定。<br/>剩余时间:

 password_error_five_times = 您已经输错5次。请5分钟后再试。

 password_error_account_lock_time = 您的账户已被锁定。<br/>请稍后再试。

diff --git a/lynq/R305/ap/app/zte_webui/js/com.js b/lynq/R305/ap/app/zte_webui/js/com.js
index cc93b65..6f3f0a1 100755
--- a/lynq/R305/ap/app/zte_webui/js/com.js
+++ b/lynq/R305/ap/app/zte_webui/js/com.js
@@ -91,7 +91,8 @@
         function prepare(values, isPost) {

             var obj = {

                 goformId: "LOGIN",

-                password: config.PASSWORD_ENCODE ? Base64.encode(values.password) : values.password

+                password: config.PASSWORD_ENCODE ? Base64.encode(values.password) : values.password,

+                username: config.PASSWORD_ENCODE ? Base64.encode(values.username) : values.username

             };

             return obj;

         }

@@ -8165,6 +8166,7 @@
             target.loginSecuritySupport = ko.observable(config.LOGIN_SECURITY_SUPPORT);

             target.newPIN               = ko.observable();			

             target.password             = ko.observable();

+            target.username             = ko.observable();

             target.PIN                  = ko.observable();

             target.pinNumber            = ko.observable(data.pinnumber);			

             target.PUK                  = ko.observable();

@@ -8224,6 +8226,7 @@
                 var ciphertext = "";

                 if (config.PASSWORD_ENCODE) {

 		    ciphertext = target.password();

+            var username = target.username();

 		} else {

                     var kparam = service.getDeviceInfoLow();

                     var tkey = CryptoJS.enc.Latin1.parse(kparam.skey);

@@ -8235,7 +8238,8 @@
                         }).toString();

 		}

                 service.login({

-                    password:ciphertext

+                    password:ciphertext,

+                    username: username

                 }, function (info) {

                     setTimeout(function () {

                         timer = loginStatusCheckingTimer();

@@ -8252,6 +8256,7 @@
                         logout.init();

                     } else {

                         target.password("");

+                        target.username("");

                         if(config.LOGIN_SECURITY_SUPPORT){

                             target.checkLoginData(function(){

                                 if (target.loginCount() == config.MAX_LOGIN_COUNT) {

@@ -8336,9 +8341,12 @@
             function setFocus(){

                 setTimeout(function () {

                     var txtAdmin = $('#txtAdmin:visible');

+                    var txtUser = $('#txtUser:visible');

                     var txtPIN = $('#txtPIN:visible');

                     var txtPUK = $('#txtPUK:visible');

-                    if (txtAdmin.length > 0) {

+                    if(txtUser.length > 0) {

+                        txtUser.focus();

+                    } else if (txtAdmin.length > 0) {

                         txtAdmin.focus();

                     } else if (txtPIN.length > 0) {

                         txtPIN.focus();

diff --git a/lynq/R305/ap/app/zte_webui/subpg/entry.html b/lynq/R305/ap/app/zte_webui/subpg/entry.html
index b293ae8..53df5c4 100755
--- a/lynq/R305/ap/app/zte_webui/subpg/entry.html
+++ b/lynq/R305/ap/app/zte_webui/subpg/entry.html
@@ -16,6 +16,11 @@
 			</div>

             <div class="row form-group">

                 <div class="col-xs-8">

+                    <input id="txtUser" autocomplete="off" data-placeholder="username" data-bind="value:username, valueUpdate: 'keypress'"  maxlength="32" name="txtUser" style="border:2px solid rgb(221, 221, 221);" class="required form-control"/>

+                </div>

+            </div>

+            <div class="row form-group">

+                <div class="col-xs-8">

                     <input id="txtAdmin" autocomplete="off" data-placeholder="password" data-bind="value:password, valueUpdate: 'keypress'"  maxlength="32" name="txtAdmin" style="border:2px solid rgb(221, 221, 221);" type="password" class="required form-control"/>

                 </div>

                 <div class="col-xs-4">