Fixed bug where you would not be able to login once you changed your password.
authorkenstir <kenstir@gmail.com>
Tue, 8 Dec 2015 01:45:15 +0000 (20:45 -0500)
committerkenstir <kenstir@gmail.com>
Tue, 8 Dec 2015 01:45:15 +0000 (20:45 -0500)
* On LOGIN_FAILED, remove the account password.  Still the auth fails but
  when you retry we forward to the authenticator with the correct
  username/password.
* Slight cleanup to SplashActivity.

Open-ILS/src/Android/core/res/layout/activity_splash.xml
Open-ILS/src/Android/core/src/org/evergreen_ils/auth/AccountAuthenticator.java
Open-ILS/src/Android/core/src/org/evergreen_ils/auth/AuthenticatorActivity.java
Open-ILS/src/Android/core/src/org/evergreen_ils/auth/Const.java
Open-ILS/src/Android/core/src/org/evergreen_ils/auth/EvergreenAuthenticator.java
Open-ILS/src/Android/core/src/org/evergreen_ils/views/splashscreen/LoadingTask.java
Open-ILS/src/Android/core/src/org/evergreen_ils/views/splashscreen/SplashActivity.java

index 4330cd8..0478013 100644 (file)
             android:contentDescription="@string/ou_library_name" />
     
         <TextView
-            android:id="@+id/action_in_progress"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_below="@+id/logo"
-            android:gravity="center"
-            android:paddingTop="10dip" />
+                android:id="@+id/action_in_progress"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_below="@+id/logo"
+                android:layout_marginTop="15dip"
+                android:gravity="center"
+                style="@style/textLarge"
+                android:paddingTop="10dip" android:text="Signing in"/>
 
         <Button
             android:id="@+id/activity_splash_retry_button"
@@ -44,6 +46,6 @@
             android:layout_height="wrap_content"
             android:layout_below="@+id/action_in_progress"
             android:layout_centerHorizontal="true"
-            android:paddingTop="40dip" />
+            android:padding="20dip" />
 
 </RelativeLayout>
\ No newline at end of file
index 8c4ec45..773fde6 100644 (file)
@@ -13,7 +13,7 @@ import android.util.Log;
 
 public class AccountAuthenticator extends AbstractAccountAuthenticator {
     
-    private final static String TAG = AccountAuthenticator.class.getSimpleName();
+    private final static String TAG = AccountAuthenticator.class.getName();
     private Context context;
 
     public AccountAuthenticator(Context context) {
@@ -63,11 +63,13 @@ public class AccountAuthenticator extends AbstractAccountAuthenticator {
                     Log.d(TAG, "getAuthToken> signIn returned token "+authToken);
                 } catch (AuthenticationException e) {
                     Log.d(TAG, "getAuthToken> caught auth exception", e);
+                    am.clearPassword(account);
                     final Bundle result = new Bundle();
                     result.putString(AccountManager.KEY_ERROR_MESSAGE, e.getMessage());
                     return result;
                 } catch (Exception e2) {
                     Log.d(TAG, "getAuthToken> caught exception", e2);
+                    am.clearPassword(account);
                     final Bundle result = new Bundle();
                     result.putString(AccountManager.KEY_ERROR_MESSAGE, "Sign in failed");
                     return result;
index 90c7b88..086f39b 100644 (file)
@@ -38,7 +38,7 @@ import java.util.*;
 
 public class AuthenticatorActivity extends AccountAuthenticatorActivity {
 
-    private final static String TAG = AuthenticatorActivity.class.getSimpleName();
+    private final static String TAG = AuthenticatorActivity.class.getName();
 
     public final static String ARG_ACCOUNT_TYPE = "ACCOUNT_TYPE";
     public final static String ARG_AUTH_TYPE = "AUTH_TYPE";
index 1085f1d..70b6990 100644 (file)
@@ -1,10 +1,9 @@
 package org.evergreen_ils.auth;
 
 public class Const {
-    //public static final String ACCOUNT_TYPE = "org.evergreen_ils";
     public static final String AUTHTOKEN_TYPE = "opac";
     public static final String AUTHTOKEN_TYPE_LABEL = "Online Public Access Catalog";
     public static final String KEY_LIBRARY_NAME = "library_name";
     public static final String KEY_LIBRARY_URL = "library_url";
-    public final static String AUTH_TAG = "eg_auth:";
+    public final static String AUTH_TAG = "eg_auth";
 }
index f895396..1952b79 100644 (file)
@@ -15,7 +15,7 @@ import android.text.TextUtils;
 import android.util.Log;
 
 public class EvergreenAuthenticator {
-    private final static String TAG = EvergreenAuthenticator.class.getSimpleName();
+    private final static String TAG = EvergreenAuthenticator.class.getName();
     public final static String SERVICE_AUTH = "open-ils.auth";
     public final static String METHOD_AUTH_INIT = "open-ils.auth.authenticate.init";
     public final static String METHOD_AUTH_COMPLETE = "open-ils.auth.authenticate.complete";
@@ -67,7 +67,6 @@ public class EvergreenAuthenticator {
         return null;
     }
     
-    @SuppressWarnings("unchecked")
     public static String signIn(String library_url, String username, String password) throws AuthenticationException {
         Log.d(TAG, "signIn> "+username+" "+library_url);
 
@@ -106,12 +105,11 @@ public class EvergreenAuthenticator {
             return authtoken;
         } else if (textcode.equals("LOGIN_FAILED")) {
             String desc = ((Map<String, String>) resp).get("desc");
-            Log.d(TAG, "desc: "+desc);
+            Log.d(TAG, "desc: " + desc);
             if (!TextUtils.isEmpty(desc)) {
                 throw new AuthenticationException(desc);
             }
         }
-        
         throw new AuthenticationException("Login failed");
     }
 }
index ce04040..ca82208 100644 (file)
@@ -24,6 +24,7 @@ import org.evergreen_ils.R;
 import org.evergreen_ils.accountAccess.AccountAccess;
 import org.evergreen_ils.accountAccess.AccountUtils;
 import org.evergreen_ils.accountAccess.SessionNotFoundException;
+import org.evergreen_ils.auth.Const;
 import org.evergreen_ils.globals.AppPrefs;
 import org.evergreen_ils.globals.GlobalConfigs;
 
@@ -97,8 +98,11 @@ public class LoadingTask {
             Bundle bnd = AccountUtils.getAuthToken(mCallingActivity);
             String auth_token = bnd.getString(AccountManager.KEY_AUTHTOKEN);
             String account_name = bnd.getString(AccountManager.KEY_ACCOUNT_NAME);
-            if (TextUtils.isEmpty(auth_token) || TextUtils.isEmpty(account_name))
-                return "no account";
+            String error_msg = bnd.getString(AccountManager.KEY_ERROR_MESSAGE);
+            if (TextUtils.isEmpty(auth_token) || TextUtils.isEmpty(account_name)) {
+                if (TextUtils.isEmpty(error_msg)) error_msg = "Login failed";
+                return error_msg;
+            }
 
             Library library = AccountUtils.getLibraryForAccount(mCallingActivity, account_name, accountType);
             AppPrefs.setString(AppPrefs.LIBRARY_NAME, library.name);
index 68c04ed..16555b2 100644 (file)
@@ -179,9 +179,9 @@ public class SplashActivity extends Activity implements LoadingTaskListener {
         } else {
             String extra_text;
             if (!TextUtils.isEmpty(result))
-                extra_text = "...failed:\n" + result;
+                extra_text = " failed:\n" + result;
             else
-                extra_text = "...cancelled";
+                extra_text = " cancelled";
             Log.d(TAG, "progresstext += " + extra_text);
             mProgressText.setText(mProgressText.getText() + extra_text);
             mRetryButton.setVisibility(View.VISIBLE);