Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line numberDiff line numberDiff line change
Expand Up@@ -76,9 +76,13 @@ public class EnterpriseLoginActivity extends BaseActivity{
private final String CLOSE_2FA_TIP = "关闭两步验证"
private String TAG_HOST_NEED_CAPTCHA = "TAG_HOST_NEED_CAPTCHA"
private final String TAG_LOGIN = "TAG_LOGIN"
private final String CE_INFO = "CE_INFO"

private static final int RESULT_CLOSE = 100;

private String ssoType = "default"
private boolean ssoEnabled = false;

@Extra
Uri background;

Expand DownExpand Up@@ -299,11 +303,8 @@ public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Thr

@Click
protected final void loginButton(){
if (layout2fa.getVisibility() == View.GONE){
login();
} else{
login2fa();
}
updateGlobalHost();
getNetwork(Global.HOST_API + "/enterprise/info/ce", CE_INFO);
}

private void login2fa(){
Expand All@@ -321,7 +322,7 @@ private void login2fa(){
Global.popSoftkeyboard(this, edit2FA, false);
}

private void login(){
private void login(boolean sha1){
try{
String name = editName.getTextString();
String password = editPassword.getTextString();
Expand All@@ -340,7 +341,11 @@ private void login(){
RequestParams params = new RequestParams();

params.put("account", name);
params.put("password", SimpleSHA1.sha1(password));
if (sha1){
params.put("password", SimpleSHA1.sha1(password));
} else{
params.put("password", password);
}
if (captchaLayout.getVisibility() == View.VISIBLE){
params.put("j_captcha", captcha);
}
Expand All@@ -359,6 +364,10 @@ private void login(){
}
}

private void login(){
login(true);
}

private void updateGlobalHost(){
if (isPrivate){
EnterpriseApp.setPrivateHost(privateHost.getTextString());
Expand DownExpand Up@@ -455,6 +464,25 @@ public void parseJson(int code, JSONObject respanse, String tag, int pos, Object
loginFail(code, respanse, true);
}

} else if (tag.equals(CE_INFO)){
if (code == 0){
try{
ssoEnabled = respanse.getJSONObject("data").getJSONObject("settings").getBoolean("ssoEnabled");
ssoType = respanse.getJSONObject("data").getJSONObject("settings").getString("ssoType");
} catch (Exception e){
ssoEnabled = false;
ssoType = "default"
}
if (layout2fa.getVisibility() == View.GONE){
if (ssoEnabled && "ldap".equals(ssoType)){
login(false);
} else{
login();
}
} else{
login2fa();
}
}
} else if (tag.equals(TAG_HOST_USER_NEED_2FA)){
if (code == 0){
loginSuccess(respanse);
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -155,6 +155,7 @@
android:text="企业账号登录"
android:textColor="@color/white"
android:textSize="17sp"
android:visibility="invisible"
app:rv_backgroundColor="@color/font_2"
app:rv_cornerRadius="4dp" />

Expand Down