From 6907710f513deb9c443d008b5960ee3d74f10f7e Mon Sep 17 00:00:00 2001 From: wiecktobi Date: Mon, 25 May 2020 23:20:23 +0200 Subject: [PATCH] Create private file with JWT --- .../java/de/hft/geotracker/activities/Login.kt | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/android/app/src/main/java/de/hft/geotracker/activities/Login.kt b/android/app/src/main/java/de/hft/geotracker/activities/Login.kt index 9857068..53f4636 100644 --- a/android/app/src/main/java/de/hft/geotracker/activities/Login.kt +++ b/android/app/src/main/java/de/hft/geotracker/activities/Login.kt @@ -1,6 +1,7 @@ package de.hft.geotracker.activities import android.Manifest +import android.content.Context import android.content.Intent import android.content.pm.PackageManager import android.os.Bundle @@ -81,13 +82,16 @@ class Login : AppCompatActivity() { call.enqueue(object : Callback { override fun onResponse(call: Call?, response: Response?) { if(response != null && response.isSuccessful) { - var headers = response.headers() - var authentication = headers.get("Authorization") + var headers = response.headers() + var authentication = headers.get("Authorization") - token = JWToken(authentication!!) - println(response.code()) - println(token.token) - startActivity(intent) + openFileOutput("JWToken", Context.MODE_PRIVATE).use { + it.write(authentication!!.toByteArray()) + } + token = JWToken(authentication!!) + println(response.code()) + println(token.token) + startActivity(intent) } else { if (response != null) { println(response.code())