Panagiotis Triantafyllou

fixed logout

...@@ -5,7 +5,7 @@ android.buildFeatures.buildConfig = true ...@@ -5,7 +5,7 @@ android.buildFeatures.buildConfig = true
5 5
6 ext { 6 ext {
7 PUBLISH_GROUP_ID = 'ly.warp' 7 PUBLISH_GROUP_ID = 'ly.warp'
8 - PUBLISH_VERSION = '4.5.5.4m3' 8 + PUBLISH_VERSION = '4.5.5.4m4'
9 PUBLISH_ARTIFACT_ID = 'warply-android-sdk' 9 PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
10 } 10 }
11 11
......
...@@ -166,6 +166,14 @@ public class WarpUtils { ...@@ -166,6 +166,14 @@ public class WarpUtils {
166 + "app_locale"; 166 + "app_locale";
167 private static final String PREFERENCES_KEY_DARK_MODE_ENABLED = PREFERENCES_PREFIX 167 private static final String PREFERENCES_KEY_DARK_MODE_ENABLED = PREFERENCES_PREFIX
168 + "dark_mode_enabled"; 168 + "dark_mode_enabled";
169 + private static final String PREFERENCES_KEY_CLIENT_ID = PREFERENCES_PREFIX
170 + + "client_id";
171 + private static final String PREFERENCES_KEY_CLIENT_SECRET = PREFERENCES_PREFIX
172 + + "client_secret";
173 + private static final String PREFERENCES_KEY_ACCESS_TOKEN = PREFERENCES_PREFIX
174 + + "access_token";
175 + private static final String PREFERENCES_KEY_REFRESH_TOKEN = PREFERENCES_PREFIX
176 + + "refresh_token";
169 177
170 private static SharedPreferences _prefs; 178 private static SharedPreferences _prefs;
171 179
...@@ -758,6 +766,81 @@ public class WarpUtils { ...@@ -758,6 +766,81 @@ public class WarpUtils {
758 } 766 }
759 767
760 /** 768 /**
769 + * Client and Auth Access Methods
770 + */
771 + public static void saveClientAccess(Context context, String clientId, String clientSecret) {
772 + SharedPreferences.Editor editor = getPreferences(context).edit();
773 + if (!TextUtils.isEmpty(clientId)) {
774 + editor.putString(PREFERENCES_KEY_CLIENT_ID, clientId);
775 + }
776 + if (!TextUtils.isEmpty(clientSecret)) {
777 + editor.putString(PREFERENCES_KEY_CLIENT_SECRET, clientSecret);
778 + }
779 + editor.apply();
780 + }
781 +
782 + public static void saveAuthAccess(Context context, String accessToken, String refreshToken) {
783 + SharedPreferences.Editor editor = getPreferences(context).edit();
784 + if (!TextUtils.isEmpty(accessToken)) {
785 + editor.putString(PREFERENCES_KEY_ACCESS_TOKEN, accessToken);
786 + }
787 + if (!TextUtils.isEmpty(refreshToken)) {
788 + editor.putString(PREFERENCES_KEY_REFRESH_TOKEN, refreshToken);
789 + }
790 + editor.apply();
791 + }
792 +
793 + public static String getClientValue(Context context, String key) {
794 + SharedPreferences prefs = getPreferences(context);
795 + switch (key) {
796 + case "client_id":
797 + return prefs.getString(PREFERENCES_KEY_CLIENT_ID, "");
798 + case "client_secret":
799 + return prefs.getString(PREFERENCES_KEY_CLIENT_SECRET, "");
800 + default:
801 + return "";
802 + }
803 + }
804 +
805 + public static String getAuthValue(Context context, String key) {
806 + SharedPreferences prefs = getPreferences(context);
807 + switch (key) {
808 + case "access_token":
809 + return prefs.getString(PREFERENCES_KEY_ACCESS_TOKEN, "");
810 + case "refresh_token":
811 + return prefs.getString(PREFERENCES_KEY_REFRESH_TOKEN, "");
812 + default:
813 + return "";
814 + }
815 + }
816 +
817 + public static boolean hasClientAccess(Context context) {
818 + SharedPreferences prefs = getPreferences(context);
819 + return !TextUtils.isEmpty(prefs.getString(PREFERENCES_KEY_CLIENT_ID, "")) &&
820 + !TextUtils.isEmpty(prefs.getString(PREFERENCES_KEY_CLIENT_SECRET, ""));
821 + }
822 +
823 + public static boolean hasAuthAccess(Context context) {
824 + SharedPreferences prefs = getPreferences(context);
825 + return !TextUtils.isEmpty(prefs.getString(PREFERENCES_KEY_ACCESS_TOKEN, "")) &&
826 + !TextUtils.isEmpty(prefs.getString(PREFERENCES_KEY_REFRESH_TOKEN, ""));
827 + }
828 +
829 + public static void clearClientAccess(Context context) {
830 + SharedPreferences.Editor editor = getPreferences(context).edit();
831 + editor.remove(PREFERENCES_KEY_CLIENT_ID);
832 + editor.remove(PREFERENCES_KEY_CLIENT_SECRET);
833 + editor.apply();
834 + }
835 +
836 + public static void clearAuthAccess(Context context) {
837 + SharedPreferences.Editor editor = getPreferences(context).edit();
838 + editor.remove(PREFERENCES_KEY_ACCESS_TOKEN);
839 + editor.remove(PREFERENCES_KEY_REFRESH_TOKEN);
840 + editor.apply();
841 + }
842 +
843 + /**
761 * END 844 * END
762 * New checks for sending logs to server 845 * New checks for sending logs to server
763 */ 846 */
......
...@@ -152,14 +152,14 @@ public class WarplyManager { ...@@ -152,14 +152,14 @@ public class WarplyManager {
152 String webId = WarpUtils.getWebId(Warply.getWarplyContext()); 152 String webId = WarpUtils.getWebId(Warply.getWarplyContext());
153 153
154 Map<String, Object> jsonParams = new ArrayMap<>(); 154 Map<String, Object> jsonParams = new ArrayMap<>();
155 - if (WarpUtils.isJWTEnabled(Warply.getWarplyContext())) { 155 +// if (WarpUtils.isJWTEnabled(Warply.getWarplyContext())) {
156 jsonParams.put("access_token", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("access_token")); 156 jsonParams.put("access_token", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("access_token"));
157 jsonParams.put("refresh_token", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("refresh_token")); 157 jsonParams.put("refresh_token", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("refresh_token"));
158 - } else { 158 +// } else {
159 jsonParams.put("token", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("access_token")); 159 jsonParams.put("token", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("access_token"));
160 jsonParams.put("client_id", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_id")); 160 jsonParams.put("client_id", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_id"));
161 jsonParams.put("client_secret", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_secret")); 161 jsonParams.put("client_secret", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_secret"));
162 - } 162 +// }
163 163
164 RequestBody loginRequest = RequestBody.create(MediaType.get("application/json; charset=utf-8"), (new JSONObject(jsonParams)).toString()); 164 RequestBody loginRequest = RequestBody.create(MediaType.get("application/json; charset=utf-8"), (new JSONObject(jsonParams)).toString());
165 165
......