Skip to content

Commit

Permalink
[Teacher][RC 1.10] Fix for backgrounding after qr login (#687)
Browse files Browse the repository at this point in the history
* [Teacher][RC 1.10] Fix for backgrounding after qr login

* more bug fixes
  • Loading branch information
TrevorNeedham authored Apr 3, 2020
1 parent 11d91b2 commit 09fc789
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
1 change: 0 additions & 1 deletion apps/teacher/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
<activity
android:name=".activities.LoginActivity"
android:label="@string/app_name"
android:clearTaskOnLaunch="true"
android:launchMode="singleTop"
android:theme="@style/LoginFlowTheme.Splash_Teacher"
android:windowSoftInputMode="stateHidden|adjustPan">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import com.instructure.loginapi.login.activities.BaseLoginInitActivity
import com.instructure.loginapi.login.util.QRLogin
import com.instructure.pandautils.services.PushNotificationRegistrationService
import com.instructure.pandautils.utils.ColorKeeper
import com.instructure.pandautils.utils.Const
import com.instructure.pandautils.utils.ThemePrefs
import com.instructure.pandautils.utils.Utils
import com.instructure.teacher.BuildConfig
Expand Down Expand Up @@ -80,9 +81,7 @@ class LoginActivity : BaseLoginInitActivity() {
return BuildConfig.IS_TESTING
}

override fun userAgent(): String {
return "androidTeacher"
}
override fun userAgent(): String = Const.TEACHER_USER_AGENT

/**
* ONLY USE FOR UI TESTING
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import com.instructure.loginapi.login.tasks.LogoutTask
import com.instructure.loginapi.login.util.QRLogin
import com.instructure.loginapi.login.util.QRLogin.verifySSOLoginUri
import com.instructure.pandautils.utils.Const
import com.instructure.pandautils.utils.Utils
import com.instructure.teacher.R
import com.instructure.teacher.fragments.FileListFragment
import com.instructure.teacher.router.RouteMatcher
Expand Down Expand Up @@ -78,6 +79,11 @@ class RouteValidatorActivity : FragmentActivity() {
return@tryWeave
}

// Mobile verify requires a user agent be set, multiple attempts/failures can clear this out
if(ApiPrefs.userAgent == "") {
ApiPrefs.userAgent = Utils.generateUserAgent(this@RouteValidatorActivity, Const.TEACHER_USER_AGENT)
}

val tokenResponse = QRLogin.performSSOLogin(data, this@RouteValidatorActivity, true)

// If we have a real user, this is a QR code from a masquerading web user
Expand All @@ -94,7 +100,7 @@ class RouteValidatorActivity : FragmentActivity() {

intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK)
startActivity(intent)
finish()
finishAffinity()
return@tryWeave
} catch (e: Throwable) {
// If the user wasn't already signed in, let's clear the prefs in case it was a partial success
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,4 +325,5 @@ public class Const {

// Intent String for QR Code Masquerading
public static final String QR_CODE_MASQUERADE_ID = "qrCodeMasqueradeId";
public static final String TEACHER_USER_AGENT = "androidTeacher";
}

0 comments on commit 09fc789

Please sign in to comment.