issues #811, #814 closed

parent 51e16563
...@@ -278,8 +278,8 @@ public class RestapiWrapper { ...@@ -278,8 +278,8 @@ public class RestapiWrapper {
@Override @Override
protected void onPostExecute(HttpAsyncTaskParams params) { protected void onPostExecute(HttpAsyncTaskParams params) {
if (params.error!=null) { if (params.error!=null) {
if (params.error.getCode()==401 && silentLogin!=null) { if (silentLogin!=null && !silentLogin.isValidToken(params.error, params.result)) {
// silentLogin.login(); silentLogin.login();
Log.e(LOG_TAG,"Silent login executed because of invalid token:"+params.error.getMessage()); Log.e(LOG_TAG,"Silent login executed because of invalid token:"+params.error.getMessage());
} }
else else
...@@ -319,5 +319,6 @@ public class RestapiWrapper { ...@@ -319,5 +319,6 @@ public class RestapiWrapper {
*/ */
public interface iSilentLogin { public interface iSilentLogin {
void login(); void login();
boolean isValidToken(HTTPException error, Object result);
} }
} }
...@@ -266,11 +266,7 @@ public class User { ...@@ -266,11 +266,7 @@ public class User {
* @return input feedback of the student configuration (default: "vibration") * @return input feedback of the student configuration (default: "vibration")
*/ */
public boolean delete_tape_after_delivery() { public boolean delete_tape_after_delivery() {
try { return input_feedback_on(JSON_STUDENT_ATTTRS.DELETE_STRIP);
return this.attributes_stu.getBoolean(JSON_STUDENT_ATTTRS.DELETE_STRIP);
} catch (JSONException e) {
return false;
}
} }
/** /**
......
...@@ -110,6 +110,17 @@ public class NetService implements Runnable, RestapiWrapper.iSilentLogin { ...@@ -110,6 +110,17 @@ public class NetService implements Runnable, RestapiWrapper.iSilentLogin {
} }
}); });
} }
@Override
public boolean isValidToken(RestapiWrapper.HTTPException error, Object result) {
try {
return error.getCode()!=401 || (((JSONObject)result).getString("err").equalsIgnoreCase("Invalid token undefined"));
} catch (JSONException e) {
Log.e(LOG_TAG,e.getMessage());
return true;
}
}
public boolean online() {return updated;} public boolean online() {return updated;}
public void restart_app(boolean direct_login) { public void restart_app(boolean direct_login) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment