Skip to content
This repository was archived by the owner on Jul 25, 2024. It is now read-only.

Commit d136f12

Browse files
committed
Save apikey, server to sharedPreferences while login
1 parent 6b3edd4 commit d136f12

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

app/src/main/java/com/zulip/android/AsyncLogin.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,13 @@ protected void onPostExecute(String result) {
4848
JSONObject obj = new JSONObject(result);
4949

5050
if (obj.getString("result").equals("success")) {
51-
this.app.setLoggedInApiKey(obj.getString("api_key"));
52-
this.context.openHome();
51+
if (!startedFromAddRealm) {
52+
//If new Realm is to be created then everything will be processed in LoginActivity!
53+
this.app.setLoggedInApiKey(obj.getString("api_key"));
54+
this.app.saveServer(serverURL, realmName);
55+
this.context.openHome();
56+
}
5357
callback.onTaskComplete(result);
54-
5558
return;
5659
}
5760
} catch (JSONException e) {

app/src/main/java/com/zulip/android/ZulipApp.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,15 @@ public void switchToRealm(int position) {
297297
edit.apply();
298298
}
299299
}
300+
public void setLoggedInApiKeyAndEmail(String apiKey, String email) {
301+
this.api_key = apiKey;
302+
Editor ed = this.settings.edit();
303+
this.you = Person.getOrUpdate(this, email, null, null);
304+
ed.putString("email", email);
305+
ed.putString("api_key", api_key);
306+
ed.apply();
307+
afterLogin();
308+
}
300309
public void saveServer(String server, String name) {
301310
SharedPreferences.Editor globalEditor = this.globalSettings.edit();
302311
serverStringSet.add(name);

0 commit comments

Comments
 (0)