Skip to content

Commit fd40cbf

Browse files
committed
identifies bad credentials situation
1 parent 72e787f commit fd40cbf

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

src/com/udinic/accounts_authenticator_example/authentication/AuthenticatorActivity.java

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import android.util.Log;
1010
import android.view.View;
1111
import android.widget.TextView;
12+
import android.widget.Toast;
1213
import com.udinic.accounts_authenticator_example.R;
1314

1415
import static com.udinic.accounts_authenticator_example.authentication.AccountGeneral.sServerAuthenticate;
@@ -87,18 +88,27 @@ protected Intent doInBackground(String... params) {
8788

8889
String authtoken = sServerAuthenticate.userSignIn(userName, userPass, mAuthTokenType);
8990

90-
final Intent res = new Intent();
91-
res.putExtra(AccountManager.KEY_ACCOUNT_NAME, userName);
92-
res.putExtra(AccountManager.KEY_ACCOUNT_TYPE, accountType);
93-
res.putExtra(AccountManager.KEY_AUTHTOKEN, authtoken);
94-
res.putExtra(PARAM_USER_PASS, userPass);
95-
96-
return res;
91+
if (authtoken == null)
92+
return null;
93+
else {
94+
final Intent res = new Intent();
95+
res.putExtra(AccountManager.KEY_ACCOUNT_NAME, userName);
96+
res.putExtra(AccountManager.KEY_ACCOUNT_TYPE, accountType);
97+
res.putExtra(AccountManager.KEY_AUTHTOKEN, authtoken);
98+
res.putExtra(PARAM_USER_PASS, userPass);
99+
100+
return res;
101+
}
97102
}
98103

99104
@Override
100105
protected void onPostExecute(Intent intent) {
101-
finishLogin(intent);
106+
if (intent != null) {
107+
finishLogin(intent);
108+
} else {
109+
Toast.makeText(getBaseContext(), "Wrong credentials", Toast.LENGTH_SHORT).show();
110+
finish();
111+
}
102112
}
103113
}.execute();
104114
}

src/com/udinic/accounts_authenticator_example/authentication/ParseComServerAuthenticate.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public String userSignIn(String user, String pass, String authType) {
107107
e.printStackTrace();
108108
}
109109

110-
return "55"+authtoken;
110+
return authtoken;
111111
}
112112

113113
private class User implements Serializable {

0 commit comments

Comments
 (0)