-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: eula on registration and sign in
- Loading branch information
Showing
18 changed files
with
303 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
auth/src/main/java/org/openedx/auth/presentation/AgreementProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package org.openedx.auth.presentation | ||
|
||
import androidx.compose.ui.text.intl.Locale | ||
import org.openedx.auth.R | ||
import org.openedx.core.ApiConstants | ||
import org.openedx.core.config.Config | ||
import org.openedx.core.domain.model.RegistrationField | ||
import org.openedx.core.domain.model.RegistrationFieldType | ||
import org.openedx.core.system.ResourceManager | ||
|
||
class AgreementProvider( | ||
private val config: Config, | ||
private val resourceManager: ResourceManager, | ||
) { | ||
internal fun getAgreement(isSignIn: Boolean): RegistrationField? { | ||
val agreementConfig = config.getAgreement(Locale.current.language) | ||
if (agreementConfig.eulaUrl.isBlank()) return null | ||
val agreementRes = if (isSignIn) { | ||
R.string.auth_agreement_signin_in | ||
} else { | ||
R.string.auth_agreement_creating_account | ||
} | ||
val eula = resourceManager.getString( | ||
R.string.auth_cdata_template, | ||
agreementConfig.eulaUrl, | ||
resourceManager.getString(R.string.auth_agreement_eula) | ||
) | ||
val tos = resourceManager.getString( | ||
R.string.auth_cdata_template, | ||
agreementConfig.tosUrl, | ||
resourceManager.getString(R.string.auth_agreement_tos) | ||
) | ||
val privacy = resourceManager.getString( | ||
R.string.auth_cdata_template, | ||
agreementConfig.privacyPolicyUrl, | ||
resourceManager.getString(R.string.auth_agreement_privacy) | ||
) | ||
val text = resourceManager.getString( | ||
agreementRes, | ||
eula, | ||
tos, | ||
config.getPlatformName(), | ||
privacy, | ||
) | ||
return RegistrationField( | ||
name = ApiConstants.RegistrationFields.HONOR_CODE, | ||
label = text, | ||
type = RegistrationFieldType.PLAINTEXT, | ||
placeholder = "", | ||
instructions = "", | ||
exposed = false, | ||
required = false, | ||
restrictions = RegistrationField.Restrictions(), | ||
options = emptyList(), | ||
errorInstructions = "" | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.