issues #811, #814 closed

parent 51e16563
......@@ -278,8 +278,8 @@ public class RestapiWrapper {
@Override
protected void onPostExecute(HttpAsyncTaskParams params) {
if (params.error!=null) {
if (params.error.getCode()==401 && silentLogin!=null) {
// silentLogin.login();
if (silentLogin!=null && !silentLogin.isValidToken(params.error, params.result)) {
silentLogin.login();
Log.e(LOG_TAG,"Silent login executed because of invalid token:"+params.error.getMessage());
}
else
......@@ -319,5 +319,6 @@ public class RestapiWrapper {
*/
public interface iSilentLogin {
void login();
boolean isValidToken(HTTPException error, Object result);
}
}
......@@ -266,11 +266,7 @@ public class User {
* @return input feedback of the student configuration (default: "vibration")
*/
public boolean delete_tape_after_delivery() {
try {
return this.attributes_stu.getBoolean(JSON_STUDENT_ATTTRS.DELETE_STRIP);
} catch (JSONException e) {
return false;
}
return input_feedback_on(JSON_STUDENT_ATTTRS.DELETE_STRIP);
}
/**
......
......@@ -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 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