I want to add banning to my Save it scenario, so you have to wait 1 day before you can access your account again if you typed a wrong password 3 times.
This is my code to save the date of banning in UserInfo:
The only problem is that the string 'string' is empty, which means that 'beginObject' is null, and it will always return false.
I don't know what I did wrong, so if somebody can help, thank you!
private static final int BANNING_INDEX = 2;
[...]
public void banUser()
{
if (this.info != null) {
long currentTime = System.currentTimeMillis();
Long object = new Long(currentTime);
this.info.setString(BANNING_INDEX, object.toString());
}
}
public boolean isUserBanned()
{
if (this.info != null) {
String string = this.info.getString(BANNING_INDEX);
System.out.print("in isUserBanned: " + string + "\n");
Long beginObject = Long.getLong(string);
if (beginObject == null) {
return false;
}
long banBegin = beginObject.longValue();
long day = 1000*60*60*24;
long currentTime = System.currentTimeMillis();
if (banBegin + day <= currentTime) {
return false;
} else {
return true;
}
}
return false;
}


