diff --git a/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/ResultFragment.kt b/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/ResultFragment.kt index cce59bb..a6a771a 100644 --- a/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/ResultFragment.kt +++ b/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/ResultFragment.kt @@ -47,17 +47,20 @@ class ResultFragment : Fragment() { /** * Only used when the MobileAuthApp was launched by an app. Not for website use. + * Not really the safest way of doing things, but sufficient for POC purposes. */ private fun createResponse( success: Boolean = true, idCode: String = "noCode", - name: String = "noName" + name: String = "noName", + authority: String = "noAuthority" ) { val responseCode = if (success) AppCompatActivity.RESULT_OK else AppCompatActivity.RESULT_CANCELED val resultIntent = Intent() resultIntent.putExtra("idCode", idCode) resultIntent.putExtra("name", name) + resultIntent.putExtra("authority", authority) requireActivity().setResult(responseCode, resultIntent) requireActivity().finish() } @@ -82,6 +85,7 @@ class ResultFragment : Fragment() { .setJsonObjectBody(json) .asJsonObject() .setCallback { e, result -> + Log.i("resultTag", result.toString()) if (result == null) { if (args.mobile) { createResponse(false) @@ -90,11 +94,11 @@ class ResultFragment : Fragment() { } } else { if (args.mobile) { - Log.i("myResultTag", result.toString()) val userData = result.asJsonObject["userData"] val idCode = userData.asJsonObject["idCode"].asString val name = userData.asJsonObject["name"].asString - createResponse(true, idCode, name) + val authority = result.asJsonObject["roles"].asJsonArray[0].asJsonObject["authority"].asString + createResponse(true, idCode, name, authority) } else { requireActivity().finishAndRemoveTask() } diff --git a/TestMobileApp/app/src/main/java/com/example/testmobileapp/MainActivity.kt b/TestMobileApp/app/src/main/java/com/example/testmobileapp/MainActivity.kt index f1feea2..d03a26a 100644 --- a/TestMobileApp/app/src/main/java/com/example/testmobileapp/MainActivity.kt +++ b/TestMobileApp/app/src/main/java/com/example/testmobileapp/MainActivity.kt @@ -14,7 +14,7 @@ import org.json.JSONObject /** * Base url where the requests should be made. Add yours here. It must use https. */ -private const val BASE_URL = "https://e871-2001-7d0-88a4-b880-d085-ba91-1799-76e7.ngrok.io" +private const val BASE_URL = "https://a0fe-2001-7d0-88ab-b880-7571-cba0-5db2-11b7.ngrok.io" private const val AUTH_URL = "$BASE_URL/auth/login" private const val CHALLENGE_URL = "$BASE_URL/auth/challenge" @@ -38,6 +38,7 @@ class MainActivity : AppCompatActivity() { // Logs are used to show what information can be retrieved from the mobileauthapp. Log.i("getResult", response.data?.getStringExtra("idCode").toString()) Log.i("getResult", response.data?.getStringExtra("name").toString()) + Log.i("getResult", response.data?.getStringExtra("authority").toString()) var user = "" try { user = response.data?.getStringExtra("name").toString()