Commit eb36974c authored by Niklas Fix's avatar Niklas Fix 🎓

fix bugs in change password screen

parent e21d4f6e
......@@ -68,6 +68,7 @@ class ChangePasswordActivity :
override fun showPasswordIncorrect() {
Snackbar.make(findViewById(R.id.coordinator_change_password),
getString(R.string.failed_to_change_password) + getString(R.string.error_invalid_password), Snackbar.LENGTH_LONG).show()
changepw_current.error = getString(R.string.error_invalid_password)
}
override fun showPasswordsMismatch() {
......@@ -80,8 +81,16 @@ class ChangePasswordActivity :
getString(R.string.failed_to_change_password) + getString(R.string.error_invalid_password_short), Snackbar.LENGTH_LONG).show()
}
override fun showOldPasswordEmpty() {
changepw_current.error = getString(R.string.please_enter_your_current_password)
}
override fun showUpdatingPassword() {
changepw_progress_text.text = getString(R.string.updating_password)
changepw_progress_container.visibility = View.VISIBLE
}
override fun handleUnauthorizedEvent() {
//Don't handle unauthorized event
}
}
......@@ -17,6 +17,7 @@ interface ChangePasswordContract {
fun showPasswordsMismatch()
fun showPasswordTooShort()
fun showUpdatingPassword()
fun showOldPasswordEmpty()
/** Hide the indeterminate progress bar, that is shown to the user while processing the changed password **/
fun hideProgress()
}
......
......@@ -17,8 +17,13 @@ class ChangePasswordPresenter(private val interactor: PasswordInteractor,
override fun changePassword(user: User, currentPw: String, newPw: String, newPw2: String) {
if (currentPw.isEmpty()) {
view?.showOldPasswordEmpty()
return
}
// Check if new passwords are valid
if(!isPasswordValid(newPw, newPw2) || currentPw.isEmpty()) {
if(!isPasswordValid(newPw, newPw2)) {
return
}
......@@ -58,7 +63,8 @@ class ChangePasswordPresenter(private val interactor: PasswordInteractor,
private fun isPasswordValid(newPw: String, newPw2: String) : Boolean {
if(newPw.isEmpty() || newPw2.isEmpty()) {
if(newPw.isEmpty() || newPw2.isEmpty() || newPw.length < 8) {
view?.showPasswordTooShort()
return false
}
......@@ -67,11 +73,6 @@ class ChangePasswordPresenter(private val interactor: PasswordInteractor,
return false
}
if(newPw.length < 6) {
view?.showPasswordTooShort()
return false
}
return true
}
......
......@@ -217,4 +217,5 @@
<string name="failed_to_send_email">Email konnte nicht gesendet werden aufgrund von %1$s</string>
<string name="no_such_user">Leider konnten wir diesen Nutzer nicht finden. Stelle bitte sicher, dass du dich nicht vertippt hast.</string>
<string name="forgot_your_password">Passwort vergessen?</string>
<string name="please_enter_your_current_password">Bitte gib dein aktuelles Passwort ein.</string>
</resources>
\ No newline at end of file
......@@ -269,4 +269,5 @@
<string name="failed_to_send_email">Failed to send email due to: %1$s</string>
<string name="no_such_user">Unfortunatelly, we could not find the specified user. Please make sure you have no typos.</string>
<string name="forgot_your_password">Forgot your password?</string>
<string name="please_enter_your_current_password">Please enter your current password.</string>
</resources>
......@@ -330,4 +330,5 @@
<string name="failed_to_send_email">Failed to send email due to: %1$s</string>
<string name="forgot_your_password">Forgot your password?</string>
<string name="no_such_user">Unfortunatelly, we could not find the specified user. Please make sure you have no typos.</string>
<string name="please_enter_your_current_password">Please enter your current password.</string>
</resources>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment