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

Added reset password #350

Merged
merged 8 commits into from
May 26, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,13 @@ class AuthenticationActivityTest {
Intents.intended(IntentMatchers.hasComponent(MyProfileActivity::class.java.name))
}

@Test
fun correctResetPassword() {
val email = "incorrectEmail"

onView(withId(R.id.username)).perform(ViewActions.typeText(email), closeSoftKeyboard())
onView(withId(R.id.forgotPassword)).perform(click())

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra space here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, already addressed this one, since there's no way to test Toast I deleted this test :(

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ class AuthenticationActivity : AppCompatActivity() {
signInGoogle()
}

/**
* Listener bound to the "Reset Password" button in the Authentication activity.
*/
fun resetPasswordListener(view: View) {
resetPassword(username.text.toString())
}

/**
* Listener bound to the red return button in the Authentication activity.
*/
Expand Down Expand Up @@ -249,5 +256,15 @@ class AuthenticationActivity : AppCompatActivity() {
private fun updateOnFail(text: String = "Authentication failed"){
Toast.makeText(baseContext, text, Toast.LENGTH_SHORT).show()
}

/**
* Reset Password function
* @param email email adress for the password reset
*/
private fun resetPassword(email: String) {
auth.sendPasswordResetEmail(email).addOnFailureListener {
Toast.makeText(baseContext, R.string.authentication_forgotPassword, Toast.LENGTH_SHORT).show()
}
}
Comment on lines +260 to +268
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe could have been into FirebaseAuth module no ?


}
11 changes: 11 additions & 0 deletions app/src/main/res/layout/activity_authentication.xml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,17 @@
android:text="@string/authentication_createAcc"
android:translationZ="10dp" />

<Button
android:id="@+id/forgotPassword"
android:layout_width="205dp"
android:layout_height="48dp"
android:backgroundTint="@color/cg_blue"
android:elevation="10dp"
android:onClick="resetPasswordListener"
android:stateListAnimator="@null"
android:text="@string/authentication_forgotPassword"
android:translationZ="10dp" />

</LinearLayout>
</ScrollView>

Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
<string name="authentication_createAcc">Create Account</string>
<string name="authentication_logIn">Log in</string>
<string name="authentication_googleLogIn">Log in with Google</string>
<string name="authentication_forgotPassword">Forgot Password</string>
<string name="authentication_emptyField">Empty email or password</string>
<string name="authentication_notAnEmail">Not an email</string>
<string name="authentication_shortPassword">Password has to be at least 6 symbols</string>
<string name="authentication_resetPasswordError">Failed to send password recovery email</string>

<!-- QrScanning -->
<string name="qrScanning_scannerClosed">Scanner has been closed</string>
Expand Down