Skip to content
This repository has been archived by the owner on Sep 15, 2024. It is now read-only.

Commit

Permalink
Fix message
Browse files Browse the repository at this point in the history
  • Loading branch information
qhy040404 committed Jun 5, 2023
1 parent d35f136 commit e8ce82f
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ object Constants {
const val NET_TIMEOUT = "Timeout"
const val NET_ERROR = "Network Unknown Error"
const val NET_DISCONNECTED = "Offline"
const val API_ERROR = "API Error"
const val STRING_NULL = ""

const val PREF_NAME = "name"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ object GlobalValues {
// Net
var netError = false
var netPrompt = Constants.STRING_NULL
var ssoPrompt = Constants.STRING_NULL

fun initBasic() {
SPUtils.spLazyMgr.reset()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class SingleFragment : BaseFragment<FragmentSingleBinding>() {

if (Requests.initLib().not()) {
runOnUiThread {
detail.text = GlobalValues.netPrompt
detail.text = GlobalValues.ssoPrompt
}
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class YanxiujianFragment : BaseFragment<FragmentYanxiujianBinding>() {

if (Requests.initLib().not()) {
runOnUiThread {
detail.text = GlobalValues.netPrompt
detail.text = GlobalValues.ssoPrompt
}
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ class ToolsInitFragment : PreferenceFragmentCompat() {
if (data.contains("异常")) {
R.string.glb_net_api_error.getString()
} else {
GlobalValues.netPrompt
data
}
}
}
Expand Down Expand Up @@ -283,7 +283,7 @@ class ToolsInitFragment : PreferenceFragmentCompat() {
if (data.contains("error-code") || flag == "exception") {
R.string.glb_net_api_error.getString()
} else {
GlobalValues.netPrompt
data
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ abstract class BaseEduActivity : SimplePageActivity() {
fun showInitFailedAlertDialog(@StringRes title: Int) {
MaterialAlertDialogBuilder(this)
.setTitle(title)
.setMessage(GlobalValues.netPrompt)
.setMessage(GlobalValues.ssoPrompt)
.setPositiveButton(R.string.glb_ok) { _, _ ->
finish()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,10 @@ class VCardActivity : BaseActivity<ActivityVcardBinding>() {
return
}

val openid = try {
val openid =
openidOrigin.substringBetween("<input id=\"openid\" value=\"", "\" type=\"hidden\">")
} catch (_: Exception) {

if (openid.contains("统一身份")) {
withContext(Dispatchers.Main)
{
MaterialAlertDialogBuilder(this@VCardActivity)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ object GetPortalData {
URLManager.PORTAL_SSO_URL,
GlobalValues.ctSso,
URLManager.PORTAL_SSO_URL
)
).let {
if (it.not()) {
return GlobalValues.ssoPrompt
}
}
Requests.get(URLManager.PORTAL_DIRECT_URL)

return when (mode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import com.qhy040404.libraryonetap.utils.SPUtils
import com.qhy040404.libraryonetap.utils.encrypt.DesEncryptUtils
import com.qhy040404.libraryonetap.utils.extensions.decode
import com.qhy040404.libraryonetap.utils.extensions.getString
import com.qhy040404.libraryonetap.utils.extensions.hasElementIn
import com.qhy040404.libraryonetap.utils.extensions.substringBetween
import com.qhy040404.libraryonetap.utils.lazy.resettableLazy
import com.qhy040404.libraryonetap.utils.lazy.resettableManager
Expand All @@ -26,9 +25,6 @@ import java.util.concurrent.TimeUnit

@Suppress("SpellCheckingInspection")
object Requests {
private val SSO_LOGIN_FAILED_PROMPT = setOf(
"用户名密码错误", "Invalid credentials"
)

var libInitialized = false
var eduInitialized = false
Expand Down Expand Up @@ -195,11 +191,11 @@ object Requests {
val id = GlobalValues.id
val passwd = GlobalValues.passwd

GlobalValues.ssoPrompt = Constants.STRING_NULL

var loginSuccess = false
var timer = 0

var response: String

while (AppUtils.checkData(id, passwd)) {
val ltResponse = get(ssoUrl)
val ltData = runCatching {
Expand All @@ -215,7 +211,7 @@ object Requests {

Thread.sleep(200L)

response = post(
post(
ssoUrl,
loginPostData(id, passwd, ltData, rsa, ltExecution),
mt
Expand Down Expand Up @@ -249,14 +245,6 @@ object Requests {
} else {
timer++
}
} else {
if (SSO_LOGIN_FAILED_PROMPT.hasElementIn(response)) {
loginSuccess = false
GlobalValues.netPrompt = R.string.glb_invalid_credentials.getString()
break
} else {
timer++
}
}
if (timer == 2) {
netLazyMgr.reset()
Expand All @@ -271,7 +259,9 @@ object Requests {
break
}
}
return loginSuccess
return loginSuccess.also {
if (it.not()) GlobalValues.ssoPrompt = R.string.glb_invalid_credentials.getString()
}
}

private fun loginPostData(
Expand Down

0 comments on commit e8ce82f

Please sign in to comment.