forked from github/wulkanowy-mirror
@ -150,6 +150,13 @@ class LoginFormFragment : BaseFragment<FragmentLoginFormBinding>(R.layout.fragme
|
||||
}
|
||||
}
|
||||
|
||||
override fun setErrorEmailInvalid(domain: String) {
|
||||
with(binding.loginFormUsernameLayout) {
|
||||
requestFocus()
|
||||
error = getString(R.string.login_invalid_custom_email,domain)
|
||||
}
|
||||
}
|
||||
|
||||
override fun clearUsernameError() {
|
||||
binding.loginFormUsernameLayout.error = null
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import io.github.wulkanowy.utils.flowWithResource
|
||||
import io.github.wulkanowy.utils.ifNullOrBlank
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import timber.log.Timber
|
||||
import java.net.URL
|
||||
import javax.inject.Inject
|
||||
|
||||
class LoginFormPresenter @Inject constructor(
|
||||
@ -87,7 +88,14 @@ class LoginFormPresenter @Inject constructor(
|
||||
|
||||
if (!validateCredentials(email, password, host)) return
|
||||
|
||||
flowWithResource { studentRepository.getStudentsScrapper(email, password, host, symbol) }.onEach {
|
||||
flowWithResource {
|
||||
studentRepository.getStudentsScrapper(
|
||||
email,
|
||||
password,
|
||||
host,
|
||||
symbol
|
||||
)
|
||||
}.onEach {
|
||||
when (it.status) {
|
||||
Status.LOADING -> view?.run {
|
||||
Timber.i("Login started")
|
||||
@ -150,11 +158,18 @@ class LoginFormPresenter @Inject constructor(
|
||||
view?.setErrorLoginRequired()
|
||||
isCorrect = false
|
||||
}
|
||||
|
||||
if ("@" !in login && "email" in host) {
|
||||
view?.setErrorEmailRequired()
|
||||
isCorrect = false
|
||||
}
|
||||
if ("@" in login && "login" !in host && "email" !in host) {
|
||||
val emailHost = login.substringAfter("@")
|
||||
val emailDomain = URL(host).host
|
||||
if (emailHost != emailDomain) {
|
||||
view?.setErrorEmailInvalid(domain = emailDomain)
|
||||
isCorrect = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (password.isEmpty()) {
|
||||
|
@ -39,6 +39,8 @@ interface LoginFormView : BaseView {
|
||||
|
||||
fun setErrorPassIncorrect()
|
||||
|
||||
fun setErrorEmailInvalid(domain: String)
|
||||
|
||||
fun clearUsernameError()
|
||||
|
||||
fun clearPassError()
|
||||
|
Reference in New Issue
Block a user