Added automatic logout when user ID or password are changed in preferences
This commit is contained in:
parent
6d1df48a1e
commit
501beb8b12
|
@ -28,6 +28,10 @@ public class Global {
|
|||
* Request code for Login module.
|
||||
*/
|
||||
public static final int LOGIN_REQUEST_CODE = 1;
|
||||
/**
|
||||
* User logged flag
|
||||
*/
|
||||
public static boolean logged;
|
||||
/**
|
||||
* Class Module's tag name for Logcat
|
||||
*/
|
||||
|
|
|
@ -37,11 +37,11 @@ public class Preferences extends PreferenceActivity {
|
|||
/**
|
||||
* User identifier.
|
||||
*/
|
||||
String userID;
|
||||
private String userID;
|
||||
/**
|
||||
* User password.
|
||||
*/
|
||||
String userPassword;
|
||||
private String userPassword;
|
||||
|
||||
/**
|
||||
* Gets user identifier.
|
||||
|
@ -93,6 +93,12 @@ public class Preferences extends PreferenceActivity {
|
|||
SharedPreferences customSharedPreference = getSharedPreferences(
|
||||
"SWADroidSharedPrefs", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = customSharedPreference.edit();
|
||||
|
||||
//If user ID or password have changed, logout automatically to force a new login
|
||||
if(!userID.equals(customSharedPreference.getString("userIDPref", "")) ||
|
||||
!userPassword.equals(customSharedPreference.getString("userPasswordPref", ""))) {
|
||||
Global.logged = false;
|
||||
}
|
||||
|
||||
editor.putString("userIDPref", userID);
|
||||
editor.putString("userPasswordPref", userPassword);
|
||||
|
|
|
@ -40,10 +40,6 @@ public class SWADMain extends Activity {
|
|||
* Application preferences.
|
||||
*/
|
||||
protected static Preferences prefs = new Preferences();
|
||||
/**
|
||||
* Login flag.
|
||||
*/
|
||||
boolean logged = false;
|
||||
|
||||
/**
|
||||
* Shows an error message.
|
||||
|
@ -114,7 +110,7 @@ public class SWADMain extends Activity {
|
|||
|
||||
switch(requestCode) {
|
||||
case Global.LOGIN_REQUEST_CODE:
|
||||
logged = true;
|
||||
Global.logged = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user