|
@@ -1,5 +1,6 @@
|
|
|
using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
|
+using System.Text.RegularExpressions;
|
|
|
using LitJson;
|
|
|
using UnityEngine;
|
|
|
using UnityEngine.UI;
|
|
@@ -9,37 +10,112 @@ public class ChangePass : MonoBehaviour
|
|
|
public GameObject savesuccess;
|
|
|
public GameObject terror;
|
|
|
public GameObject terror2;
|
|
|
+ public GameObject terror3;
|
|
|
public InputField inputold;
|
|
|
public InputField inputnew1;
|
|
|
public InputField inputnew2;
|
|
|
+
|
|
|
+ private void OnEnable() {
|
|
|
+ inputnew1.text="";
|
|
|
+ inputnew2.text="";
|
|
|
+ inputold.text="";
|
|
|
+ terror.SetActive(false);
|
|
|
+ terror2.SetActive(false);
|
|
|
+ terror3.SetActive(false);
|
|
|
+ }
|
|
|
public void changepass()
|
|
|
{
|
|
|
- string oldpass = AesEncryption.Encrypt(inputold.text);
|
|
|
- string encrypted1 = AesEncryption.Encrypt(inputnew1.text);
|
|
|
- string encrypted2 = AesEncryption.Encrypt(inputnew1.text);
|
|
|
- if(encrypted1==encrypted2)
|
|
|
- {
|
|
|
- DataManager.Instance.setPass(oldpass,encrypted1,(msg) => {
|
|
|
- JsonData d = JsonMapper.ToObject(msg);
|
|
|
- if(d["data"]==null)
|
|
|
- {
|
|
|
- terror.SetActive(true);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- terror2.SetActive(false);
|
|
|
- terror.SetActive(false);
|
|
|
- savesuccess.SetActive(true);
|
|
|
- Invoke("savecloes",2f);
|
|
|
-
|
|
|
- }
|
|
|
+ terror.SetActive(false);
|
|
|
+ terror2.SetActive(false);
|
|
|
+ terror3.SetActive(false);
|
|
|
+
|
|
|
+ int ct =0;
|
|
|
+ string msg = "密码格式缺少:";
|
|
|
+ var pwdRegex1 = "(?=.*[0-9])";
|
|
|
+ Regex reg1 = new Regex(pwdRegex1);
|
|
|
+ bool isMatch1 = reg1.IsMatch(inputnew1.text);
|
|
|
+ if(!isMatch1)
|
|
|
+ {
|
|
|
+ msg += "数字 ";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ct++;
|
|
|
+ }
|
|
|
+ var pwdRegex2 = "(?=.*[a-z])";
|
|
|
+ Regex reg2 = new Regex(pwdRegex2);
|
|
|
+ bool isMatch2 = reg2.IsMatch(inputnew1.text);
|
|
|
+ if(!isMatch2)
|
|
|
+ {
|
|
|
+
|
|
|
+ msg += "小写字母 ";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ct++;
|
|
|
+ }
|
|
|
+ var pwdRegex3 = "(?=.*[A-Z])";
|
|
|
+ Regex reg3= new Regex(pwdRegex3);
|
|
|
+ bool isMatch3 = reg3.IsMatch(inputnew1.text);
|
|
|
+ if(!isMatch3)
|
|
|
+ {
|
|
|
+ msg += "大写字母 ";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ct++;
|
|
|
+ }
|
|
|
+ var pwdRegex4 = "[!@#$%^&*(),.?\\\":{}|<>]";
|
|
|
+ Regex reg4= new Regex(pwdRegex4);
|
|
|
+ bool isMatch4 = reg4.IsMatch(inputnew1.text);
|
|
|
+ if(!isMatch4)
|
|
|
+ {
|
|
|
+
|
|
|
+ msg += "特殊字符 ";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ct++;
|
|
|
+ }
|
|
|
+ msg+="中"+(3-ct)+"个";
|
|
|
+ if(inputnew1.text.Length<8)
|
|
|
+ {
|
|
|
+ msg = "密码必须大于8位";
|
|
|
+ }
|
|
|
+ if(ct>=3&&inputnew1.text.Length>=8)
|
|
|
+ {
|
|
|
+ string oldpass = AesEncryption.Encrypt(inputold.text);
|
|
|
+ string encrypted1 = AesEncryption.Encrypt(inputnew1.text);
|
|
|
+ string encrypted2 = AesEncryption.Encrypt(inputnew2.text);
|
|
|
+ if(encrypted1==encrypted2)
|
|
|
+ {
|
|
|
+ DataManager.Instance.setPass(oldpass,encrypted1,(msg) => {
|
|
|
+ JsonData d = JsonMapper.ToObject(msg);
|
|
|
+ if(d["data"]==null)
|
|
|
+ {
|
|
|
+ terror.SetActive(true);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ terror2.SetActive(false);
|
|
|
+ terror.SetActive(false);
|
|
|
+ savesuccess.SetActive(true);
|
|
|
+ Invoke("savecloes",2f);
|
|
|
+ }
|
|
|
|
|
|
- });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ terror2.SetActive(true);
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- terror2.SetActive(true);
|
|
|
+ terror3.GetComponent<Text>().text = msg;
|
|
|
+ terror3.SetActive(true);
|
|
|
}
|
|
|
+
|
|
|
|
|
|
}
|
|
|
void savecloes()
|