mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-30 20:52:21 -05:00
display specific error message when password is too weak on registration
This commit is contained in:
parent
198a9f2226
commit
3409399ef1
@ -110,7 +110,8 @@ public class Account extends AbstractEntity {
|
|||||||
HOST_UNKNOWN(true),
|
HOST_UNKNOWN(true),
|
||||||
REGISTRATION_PLEASE_WAIT(true),
|
REGISTRATION_PLEASE_WAIT(true),
|
||||||
STREAM_ERROR(true),
|
STREAM_ERROR(true),
|
||||||
POLICY_VIOLATION(true);
|
POLICY_VIOLATION(true),
|
||||||
|
REGISTRATION_PASSWORD_TOO_WEAK(true);
|
||||||
|
|
||||||
private final boolean isError;
|
private final boolean isError;
|
||||||
|
|
||||||
@ -118,11 +119,11 @@ public class Account extends AbstractEntity {
|
|||||||
return this.isError;
|
return this.isError;
|
||||||
}
|
}
|
||||||
|
|
||||||
private State(final boolean isError) {
|
State(final boolean isError) {
|
||||||
this.isError = isError;
|
this.isError = isError;
|
||||||
}
|
}
|
||||||
|
|
||||||
private State() {
|
State() {
|
||||||
this(false);
|
this(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,6 +165,8 @@ public class Account extends AbstractEntity {
|
|||||||
return R.string.account_status_policy_violation;
|
return R.string.account_status_policy_violation;
|
||||||
case REGISTRATION_PLEASE_WAIT:
|
case REGISTRATION_PLEASE_WAIT:
|
||||||
return R.string.registration_please_wait;
|
return R.string.registration_please_wait;
|
||||||
|
case REGISTRATION_PASSWORD_TOO_WEAK:
|
||||||
|
return R.string.registration_password_too_weak;
|
||||||
case STREAM_ERROR:
|
case STREAM_ERROR:
|
||||||
return R.string.account_status_stream_error;
|
return R.string.account_status_stream_error;
|
||||||
default:
|
default:
|
||||||
|
@ -34,6 +34,7 @@ import java.security.Principal;
|
|||||||
import java.security.PrivateKey;
|
import java.security.PrivateKey;
|
||||||
import java.security.cert.X509Certificate;
|
import java.security.cert.X509Certificate;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@ -182,21 +183,25 @@ public class XmppConnection implements Runnable {
|
|||||||
forceCloseSocket();
|
forceCloseSocket();
|
||||||
changeStatus(Account.State.REGISTRATION_SUCCESSFUL);
|
changeStatus(Account.State.REGISTRATION_SUCCESSFUL);
|
||||||
} else {
|
} else {
|
||||||
|
final List<String> PASSWORD_TOO_WEAK_MSGS = Arrays.asList(
|
||||||
|
"The password is too weak",
|
||||||
|
"Please use a longer password.");
|
||||||
Element error = packet.findChild("error");
|
Element error = packet.findChild("error");
|
||||||
if (error != null && error.hasChild("conflict")) {
|
Account.State state = Account.State.REGISTRATION_FAILED;
|
||||||
forceCloseSocket();
|
if (error != null) {
|
||||||
changeStatus(Account.State.REGISTRATION_CONFLICT);
|
if (error.hasChild("conflict")) {
|
||||||
} else if (error != null
|
state = Account.State.REGISTRATION_CONFLICT;
|
||||||
&& "wait".equals(error.getAttribute("type"))
|
} else if (error.hasChild("resource-constraint")
|
||||||
&& error.hasChild("resource-constraint")) {
|
&& "wait".equals(error.getAttribute("type"))) {
|
||||||
forceCloseSocket();
|
state = Account.State.REGISTRATION_PLEASE_WAIT;
|
||||||
changeStatus(Account.State.REGISTRATION_PLEASE_WAIT);
|
} else if (error.hasChild("not-acceptable")
|
||||||
} else {
|
&& PASSWORD_TOO_WEAK_MSGS.contains(error.findChildContent("text"))) {
|
||||||
forceCloseSocket();
|
state = Account.State.REGISTRATION_PASSWORD_TOO_WEAK;
|
||||||
changeStatus(Account.State.REGISTRATION_FAILED);
|
|
||||||
Log.d(Config.LOGTAG, packet.toString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
changeStatus(state);
|
||||||
|
forceCloseSocket();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -648,6 +648,7 @@
|
|||||||
<string name="device_does_not_support_battery_op">Your device does not support opting out of battery optimization</string>
|
<string name="device_does_not_support_battery_op">Your device does not support opting out of battery optimization</string>
|
||||||
<string name="show_password">Show password</string>
|
<string name="show_password">Show password</string>
|
||||||
<string name="registration_please_wait">Registration failed: Try again later</string>
|
<string name="registration_please_wait">Registration failed: Try again later</string>
|
||||||
|
<string name="registration_password_too_weak">Registration failed: Password too weak</string>
|
||||||
<string name="create_conference">Create conference</string>
|
<string name="create_conference">Create conference</string>
|
||||||
<string name="join_or_create_conference">Join or create conference</string>
|
<string name="join_or_create_conference">Join or create conference</string>
|
||||||
<string name="conference_subject">Subject</string>
|
<string name="conference_subject">Subject</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user