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

fix #2 password rules

parent 12b60d35
Pipeline #1929 failed with stages
in 2 minutes and 25 seconds
......@@ -50,7 +50,7 @@ class EmailFragment : Fragment(), EmailContract.View, Step {
override fun showEmailValid() {
ve = null
textinputlayout_signup_email.hint = "Email is valid"
textinputlayout_signup_email.hint = getString(R.string.email_valid)
}
override fun showEmailNotValid() {
......
......@@ -38,6 +38,16 @@ interface PasswordContract {
*/
fun showSecondPasswordTooLong()
/**
* Let the user know that the first password does not contain at least one uppercase and one lowercase letter
*/
fun showFirstPasswordNotUpperLower()
/**
* Let the user know that the second password does not contain at least one uppercase and one lowercase letter
*/
fun showSecondPasswordNotUpperLower()
/** Let the user know that the two given passwords are not equal **/
fun showPasswordsNotEqual()
}
......
......@@ -23,6 +23,7 @@ class PasswordFragment : Fragment(), PasswordContract.View, Step {
private var errorStringTooShort: String = "error"
private var errorStringTooLong: String = "error"
private var errorStringNotEqual: String = "error"
private var errorStringNotUpperLower: String = "error"
var ve1 : VerificationError? = null
var ve2 : VerificationError? = null
......@@ -41,6 +42,7 @@ class PasswordFragment : Fragment(), PasswordContract.View, Step {
errorStringTooShort = getString(R.string.error_invalid_password_short)
errorStringTooLong = getString(R.string.error_invalid_password_long)
errorStringNotEqual = getString(R.string.error_invalid_password_notequal)
errorStringNotUpperLower = getString(R.string.error_invalid_password_notupperlower)
return v
}
......@@ -56,12 +58,12 @@ class PasswordFragment : Fragment(), PasswordContract.View, Step {
override fun showFirstPasswordValid() {
ve1 = null
textinputlayout_signup_password1.hint = "Password OK!"
textinputlayout_signup_password1.hint = getString(R.string.password_ok)
}
override fun showSecondPasswordValid() {
ve2 = null
textinputlayout_signup_password2.hint = "Passwords match!"
textinputlayout_signup_password2.hint = getString(R.string.passwords_match)
}
override fun showFirstPasswordTooShort() {
......@@ -94,6 +96,18 @@ class PasswordFragment : Fragment(), PasswordContract.View, Step {
textinputedittext_signup_password2.error = errorStringNotEqual
}
override fun showFirstPasswordNotUpperLower() {
ve1 = VerificationError(errorStringNotUpperLower)
textinputlayout_signup_password1.hint = getString(R.string.hint_signup_reenterpassword)
textinputedittext_signup_password1.error = errorStringNotUpperLower
}
override fun showSecondPasswordNotUpperLower() {
ve2 = VerificationError(errorStringNotUpperLower)
textinputlayout_signup_password2.hint = getString(R.string.hint_signup_reenterpassword)
textinputedittext_signup_password2.error = errorStringNotUpperLower
}
override fun onSelected() {
}
......
......@@ -2,6 +2,7 @@ package de.akamu.tudarmstadt.features.signup.password
import com.stepstone.stepper.VerificationError
import de.akamu.tudarmstadt.util.Constants
import java.util.*
class PasswordPresenter(var view: PasswordContract.View?)
: PasswordContract.Presenter {
......@@ -30,7 +31,11 @@ class PasswordPresenter(var view: PasswordContract.View?)
}
password.length > maxLength -> {
view?.showFirstPasswordTooLong()
} else -> view?.showFirstPasswordValid()
}
!containsUpperAndLowerChar(password) -> {
view?.showFirstPasswordNotUpperLower()
}
else -> view?.showFirstPasswordValid()
}
}
......@@ -42,9 +47,13 @@ class PasswordPresenter(var view: PasswordContract.View?)
password2.length > maxLength -> {
view?.showSecondPasswordTooLong()
}
!containsUpperAndLowerChar(password2) -> {
view?.showSecondPasswordNotUpperLower()
}
password2 != password1 -> {
view?.showPasswordsNotEqual()
} else -> view?.showSecondPasswordValid()
}
else -> view?.showSecondPasswordValid()
}
}
......@@ -53,4 +62,9 @@ class PasswordPresenter(var view: PasswordContract.View?)
checkSecondPassword(password1, password2)
}
fun containsUpperAndLowerChar(password: String) : Boolean {
return password != password.toLowerCase(Locale.ROOT)
&& password != password.toUpperCase(Locale.ROOT)
}
}
\ No newline at end of file
......@@ -24,7 +24,7 @@
<string name="error_invalid_password">Falsches Passwort.</string>
<string name="logging_in">Wird eingeloggt...</string>
<string name="hint_signup_chooseusername">Wähle einen Usernamen</string>
<string name="error_invalid_password_short">Passwort muss mindestens 6 Zeichen lang sein.</string>
<string name="error_invalid_password_short">Passwort muss mindestens 8 Zeichen lang sein.</string>
<string name="error_username_notavailable">Dieser Username existiert bereits.</string>
<string name="username_available">Username verfügbar!</string>
<string name="hint_signup_reenterpassword">Passwort erneut eingeben</string>
......@@ -185,4 +185,8 @@
<string name="verifying_password">Passwort wird verifiziert.</string>
<string name="updating_password">Passwort wird geändert...</string>
<string name="used_libs">Verwendete Bibliotheken</string>
<string name="error_invalid_password_notupperlower">Das Passwort muss mindestens einen Groß- und einen Kleinbuchstaben enthalten</string>
<string name="password_ok">Passwort OK!</string>
<string name="passwords_match">Passwörter stimmen überein.</string>
<string name="email_valid">Email ist gültig</string>
</resources>
\ No newline at end of file
......@@ -18,9 +18,7 @@
<!-- Strings related to SignUp -->
<string name="hint_signup_chooseusername">Choose a username</string>
<string name="error_invalid_password_short">Password must be at least 6
characters long
</string>
<string name="error_invalid_password_short">Password must be at least 8 characters long</string>
<string name="error_invalid_password_long">Password may not have more than
50 characters
</string>
......@@ -243,4 +241,8 @@
<string name="verifying_password">Verifying password...</string>
<string name="updating_password">Updating password...</string>
<string name="used_libs">Used Libraries</string>
<string name="error_invalid_password_notupperlower">Password must contain at least one uppercase and one lowercase letter</string>
<string name="password_ok">Password OK!</string>
<string name="passwords_match">Passwords match.</string>
<string name="email_valid">Email is valid</string>
</resources>
......@@ -95,9 +95,7 @@
<!-- Strings related to SignUp -->
<string name="hint_signup_chooseusername">Choose a username</string>
<string name="error_invalid_password_short">Password must be at least 6
characters long
</string>
<string name="error_invalid_password_short">Password must be at least 8 characters long\n\t</string>
<string name="error_invalid_password_long">Password may not have more than
50 characters
</string>
......@@ -299,4 +297,8 @@
<string name="used_libs">Used Libraries</string>
<string name="pref_key_enable_crash_report"
translatable="false">pref_key_enable_crash_report</string>
<string name="error_invalid_password_notupperlower">Password must contain at least one uppercase and one lowercase letter</string>
<string name="password_ok">Password OK!</string>
<string name="passwords_match">Passwords match.</string>
<string name="email_valid">Email is valid</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