|
@@ -18,6 +18,7 @@ import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.util.Assert;
|
|
|
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
@@ -33,15 +34,15 @@ public class UserAuthService {
|
|
@Autowired
|
|
@Autowired
|
|
private PropertyService propertyService;
|
|
private PropertyService propertyService;
|
|
|
|
|
|
- public Result login(String account, String password, Long rootOrgId) throws Exception {
|
|
|
|
|
|
+ public Result<String> login(String account, String password, String accountType, Long rootOrgId, String domain) throws Exception {
|
|
//封装请求参数
|
|
//封装请求参数
|
|
final String requestUrl = String.format("%s/api/ecs_core/auth/login", propertyService.getUserAuthUrl());
|
|
final String requestUrl = String.format("%s/api/ecs_core/auth/login", propertyService.getUserAuthUrl());
|
|
Map<String, String> params = new HashMap<>();
|
|
Map<String, String> params = new HashMap<>();
|
|
params.put("accountValue", account);
|
|
params.put("accountValue", account);
|
|
params.put("password", password);
|
|
params.put("password", password);
|
|
- params.put("rootOrgId", String.valueOf(rootOrgId));
|
|
|
|
- params.put("accountType", DEFAULT_ACCOUNT_TYPE);
|
|
|
|
- params.put("domain", "");
|
|
|
|
|
|
+ params.put("accountType", accountType != null ? accountType : COMMON_ACCOUNT_TYPE);
|
|
|
|
+ params.put("rootOrgId", rootOrgId != null ? rootOrgId.toString() : "");
|
|
|
|
+ params.put("domain", domain);
|
|
String json = new JsonMapper().toJson(params);
|
|
String json = new JsonMapper().toJson(params);
|
|
RequestBody formBody = FormBody.create(MediaType.parse(Constants.CHARSET_JSON_UTF8), json);
|
|
RequestBody formBody = FormBody.create(MediaType.parse(Constants.CHARSET_JSON_UTF8), json);
|
|
Request request = new Request.Builder()
|
|
Request request = new Request.Builder()
|
|
@@ -85,10 +86,11 @@ public class UserAuthService {
|
|
}
|
|
}
|
|
|
|
|
|
public Result updatePassword(String key, String token, Long userId, String password) throws Exception {
|
|
public Result updatePassword(String key, String token, Long userId, String password) throws Exception {
|
|
|
|
+ Assert.notNull(userId, "UserId must be not null.");
|
|
//封装请求参数
|
|
//封装请求参数
|
|
final String requestUrl = String.format("%s/api/ecs_core/user/password", propertyService.getUserAuthUrl());
|
|
final String requestUrl = String.format("%s/api/ecs_core/user/password", propertyService.getUserAuthUrl());
|
|
RequestBody formBody = new FormBody.Builder()
|
|
RequestBody formBody = new FormBody.Builder()
|
|
- .add("userId", String.valueOf(userId))
|
|
|
|
|
|
+ .add("userId", userId.toString())
|
|
.add("password", password)
|
|
.add("password", password)
|
|
.build();
|
|
.build();
|
|
return HttpUtils.doPut(requestUrl, formBody, key, token);
|
|
return HttpUtils.doPut(requestUrl, formBody, key, token);
|