Skip to content

Commit

Permalink
fixup! Merge remote-tracking branch 'origin/develop' into kshitij/cus…
Browse files Browse the repository at this point in the history
…tom-auth-2
  • Loading branch information
xitij2000 committed Nov 29, 2024
1 parent 60ce739 commit 57259d9
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 9 deletions.
6 changes: 5 additions & 1 deletion app/src/main/java/org/openedx/app/AppActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ class AppActivity : AppCompatActivity(), InsetHolder, WindowSizeHolder {
private val authCode: String?
get() {
val data = intent?.data
if (data is Uri && data.scheme == BuildConfig.APPLICATION_ID && data.host == ApiConstants.BrowserLogin.REDIRECT_HOST) {
if (
data is Uri &&
data.scheme == BuildConfig.APPLICATION_ID &&
data.host == ApiConstants.BrowserLogin.REDIRECT_HOST
) {
return data.getQueryParameter(ApiConstants.BrowserLogin.CODE_QUERY_PARAM)
}
return null
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/org/openedx/app/di/ScreenModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ val screenModule = module {
)
}

viewModel { (courseId: String?, infoType: String?, authCode:String) ->
viewModel { (courseId: String?, infoType: String?, authCode: String) ->
SignInViewModel(
get(),
get(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,11 @@ class LogistrationFragment : Fragment() {
OpenEdXTheme {
LogistrationScreen(
onSignInClick = {
if(viewModel.isBrowserLoginEnabled) {
if (viewModel.isBrowserLoginEnabled) {
viewModel.signInBrowser(requireActivity())
} else {
viewModel.navigateToSignIn(parentFragmentManager)
}

},
onRegisterClick = {
if (viewModel.isBrowserRegistrationEnabled) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import org.openedx.auth.presentation.AuthAnalyticsKey
import org.openedx.auth.presentation.AuthRouter
import org.openedx.auth.presentation.sso.BrowserAuthHelper
import org.openedx.core.config.Config
import org.openedx.core.utils.Logger
import org.openedx.foundation.extension.takeIfNotEmpty
import org.openedx.foundation.presentation.BaseViewModel
import org.openedx.core.utils.Logger

class LogistrationViewModel(
private val courseId: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import org.openedx.auth.domain.interactor.AuthInteractor
import org.openedx.auth.domain.model.SocialAuthResponse
import org.openedx.auth.presentation.AgreementProvider
import org.openedx.auth.presentation.AuthAnalytics
import org.openedx.auth.presentation.sso.BrowserAuthHelper
import org.openedx.auth.presentation.AuthAnalyticsEvent
import org.openedx.auth.presentation.AuthAnalyticsKey
import org.openedx.auth.presentation.AuthRouter
import org.openedx.auth.presentation.sso.BrowserAuthHelper
import org.openedx.auth.presentation.sso.OAuthHelper
import org.openedx.core.Validator
import org.openedx.core.config.Config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ class BrowserAuthHelper(private val config: Config) {
logger.d { "Browser-based auth initiated" }
val uri = Uri.parse("${config.getApiHostURL()}${ApiConstants.URL_AUTHORIZE}").buildUpon()
.appendQueryParameter("client_id", config.getOAuthClientId())
.appendQueryParameter("redirect_uri", "${activityContext.packageName}://${ApiConstants.BrowserLogin.REDIRECT_HOST}")
.appendQueryParameter(
"redirect_uri",
"${activityContext.packageName}://${ApiConstants.BrowserLogin.REDIRECT_HOST}"
)
.appendQueryParameter("response_type", ApiConstants.BrowserLogin.RESPONSE_TYPE).build()
val intent =
CustomTabsIntent.Builder().setUrlBarHidingEnabled(true).setShowTitle(true).build()
intent.intent.setFlags(FLAG_ACTIVITY_NEW_TASK)
logger.d { "Launching custom tab with ${uri.toString()}"}
intent.launchUrl(activityContext, uri)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import org.openedx.auth.R
import org.openedx.auth.domain.interactor.AuthInteractor
import org.openedx.auth.presentation.AgreementProvider
import org.openedx.auth.presentation.AuthAnalytics
import org.openedx.auth.presentation.sso.BrowserAuthHelper
import org.openedx.auth.presentation.AuthRouter
import org.openedx.auth.presentation.sso.BrowserAuthHelper
import org.openedx.auth.presentation.sso.OAuthHelper
import org.openedx.core.Validator
import org.openedx.core.config.Config
Expand Down

0 comments on commit 57259d9

Please sign in to comment.