/// <summary> /// 登陆 /// </summary> /// <param name="company">公司</param> /// <param name="name">用户名</param> /// <param name="pwd">密码</param> /// <returns>密钥</returns> public String login(string company, string name, string pwd) { //获取用户 Account account = am.getAccount(company, name, pwd); if (account != null) { //转json后加密 return(FinanceRSA.RSAEncryption(FinanceJson.getFinanceJson().toJson(account))); } else { return(""); } }
/// <summary> /// 检查token是否有效 /// </summary> /// <param name="token">密钥</param> /// <returns>有效返回对象,无效返回null</returns> public Account checkToken(string token) { //解密 token = FinanceRSA.RSADecrypt(token); Account account = null; //json转对象 try { account = FinanceJson.getFinanceJson().toObject <Account>(token); } catch (Exception ex) { FinanceToError.getFinanceToError().toError(); } return(account); }
/// <summary> /// 用token换取Account对象 /// </summary> /// <param name="token">token字符串</param> /// <returns>Account对象</returns> public Account getAccount(string token) { //解密后转用户类型 Account account = (Account)FinanceJson.getFinanceJson().toObject <Account>(FinanceRSA.RSADecrypt(token)); return(account); }