Browse Source

调整验证密码,返回token方法

wangmh 7 years ago
parent
commit
440c9e130b
1 changed files with 26 additions and 24 deletions
  1. 26 24
      sso-common/src/main/java/com/uas/sso/util/AccountUtils.java

+ 26 - 24
sso-common/src/main/java/com/uas/sso/util/AccountUtils.java

@@ -482,30 +482,32 @@ public class AccountUtils {
 //		}
 //        return null;
 //    }
-//
-//	/**
-//	 * 验证密码,返回绑定身份信息的token
-//	 *
-//	 * @return
-//	 */
-//	public static String getAccessToken(User user) throws Exception {
-//		String saveUrl = AccountConfig.getUserSaveUrl();
-//		if (!StringUtils.isEmpty(saveUrl)) {
-//			JSONObject formData = JSON.parseObject(JSON.toJSONString(user));
-//			formData.put("_operate", "getToken");
-//			ResponseWrap res = HttpUtil.doGet(saveUrl, formData);
-//			if (!res.isSuccess())
-//				throw new Exception(res.getContent());
-//			else {
-//				ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
-//				if (!result.isSuccess())
-//					throw new Exception(result.getErrMsg());
-//				else
-//					return String.valueOf(result.getContent());
-//			}
-//		}
-//		return null;
-//	}
+
+	/**
+	 * 验证密码,返回绑定身份信息的token
+	 *
+	 * @return
+	 */
+	public static String getAccessToken(UserView user) throws Exception {
+		String saveUrl = AccountConfig.getUserSaveUrl();
+		if (!StringUtils.isEmpty(saveUrl)) {
+			JSONObject formData = JSON.parseObject(JSON.toJSONString(user));
+			formData.put("_operate", "getToken");
+			HttpUtil.ResponseWrap res = HttpUtil.doGet(saveUrl, formData);
+			if (!res.isSuccess()) {
+                throw new Exception(res.getContent());
+            } else {
+				ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
+				if (!result.isSuccess()) {
+                    throw new Exception(result.getErrMsg());
+                } else {
+                    return String.valueOf(result.getContent());
+                }
+
+			}
+		}
+		return null;
+	}
 //
 //	/**
 //	 * 验证token,返回当前应用相关的身份信息