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

Rework Authentication #180

Merged
merged 8 commits into from
Apr 18, 2022
Merged

Rework Authentication #180

merged 8 commits into from
Apr 18, 2022

Conversation

MaximeZmt
Copy link
Owner

@MaximeZmt MaximeZmt commented Apr 15, 2022

Rework Authentication (part 1)

This is related to issue #161

This Pull Requests contains:

  • Changing the welcome screen logic: if not logged in, write it to the user and when click on my account bring to authentication activity
  • If was logged in, when click on my account lead to profile activity.
  • Add of return button inside profile activity (to be extended to others)

In addition the code is tested with a coverage of: [??]%

Notes for reviewers

  • GOAL: Remove shared pref cause very buggy, will use an offline feature of firebase. Has to rework the whole authentication + storage process => Use Firebase authentication + database cache

=> I have read many docs concerning firebase, I've already spent more than 10h doing all my stuff.
Here is the first pr for the first part, the 2nd one will come later in the week.

@MaximeZmt MaximeZmt self-assigned this Apr 15, 2022
@MaximeZmt MaximeZmt changed the title doing debug Rework Apr 16, 2022
@MaximeZmt MaximeZmt changed the title Rework Rework Authentication Rework Apr 17, 2022
@MaximeZmt MaximeZmt changed the title Rework Authentication Rework Rework Authentication Apr 17, 2022
@MaximeZmt MaximeZmt added the actual: 10h actual time to fix label Apr 17, 2022
@MaximeZmt MaximeZmt marked this pull request as ready for review April 18, 2022 03:49
@@ -10,6 +10,7 @@ import com.google.firebase.ktx.Firebase

object Database {
fun get(): FirebaseDatabase {
return Firebase.database("https://vibester-sdp-default-rtdb.europe-west1.firebasedatabase.app")
val db = Firebase.database("https://vibester-sdp-default-rtdb.europe-west1.firebasedatabase.app")
return db
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we need the extra variable declaration here?

Copy link
Owner Author

Choose a reason for hiding this comment

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

no that was temporary

@kamilababayeva kamilababayeva self-requested a review April 18, 2022 09:03
Copy link
Collaborator

@laurislopata laurislopata left a comment

Choose a reason for hiding this comment

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

LGTM already just one small comment

Copy link
Collaborator

@kamilababayeva kamilababayeva left a comment

Choose a reason for hiding this comment

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

Thank you for your changes! There are several issues I ave addressed in the comments, can you respond to them? Thanks!

General comment, we should redirect user to the profile account after the user created the account. Right now, the user created account, automatically logged in, and then it is not redirected to profile account. You press go back, and the login is not displayed in the bottom of welcome page. It is resetted apparently.

@@ -76,11 +76,15 @@ class UsersRepo @Inject constructor() {
for (dataSnapShot in dataSnapshot.children) {
val dbContents = dataSnapShot.getValue<UserProfile>()
if (dbContents != null) {
Log.e("pp urepo ",dbContents.image )
Log.e("memail 1 ",dbContents.email )
Log.e("memail 2 ",email )
Copy link
Collaborator

Choose a reason for hiding this comment

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

in general, is it okay that log is there?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I am asking cause they dont respond to the error, so they are for personal testing. From the 'best' practices, should they be in the main branch of the code? If yes, then lets do more comprehensive text?

Copy link
Owner Author

Choose a reason for hiding this comment

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

no that was debug stuff and will be removed

callback(dbContents)
break
} else {
callback(UserProfile())
//callback(UserProfile())
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we remove this callback?

Copy link
Owner Author

Choose a reason for hiding this comment

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

yes this callback is wrong, cause it goes across around all player in db, and validate the login even if not the good one

Copy link
Owner Author

Choose a reason for hiding this comment

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

I will even remove the comments and clear the line

/*
val getIntent = intent.extras
if (getIntent!=null){
testLoggedIn = getIntent.getBoolean("testLoggedIn", false)
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

if not used, remove completely?

Copy link
Owner Author

Choose a reason for hiding this comment

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

yes (sorry old test stuff)



val userStatusTextValue = findViewById<TextView>(R.id.user_status)
if(FireBaseAuthenticator.isLoggedIn() || testLoggedIn)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since we are pushing to the main branch, I believe the code should be as clean as possible. So I am not sure whether the testing variables hsould be in main

Copy link
Owner Author

Choose a reason for hiding this comment

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

this is testing var for cirrus, this is necessary (trick to allow unit test to test the below code, otherwise impossible)

Copy link
Collaborator

Choose a reason for hiding this comment

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

ohhh, i seee

if (bm != null) {
Log.e(getString(R.string.log_tag), bm.height.toString() + " - " + bm.width.toString())
}else{
Log.e(getString(R.string.log_tag), "ahhhh merde")
Copy link
Collaborator

Choose a reason for hiding this comment

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

noooo no merde

Copy link
Owner Author

Choose a reason for hiding this comment

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

hahahaha forget to remove it 😅 😅 Do we see I get frustrated with that code 😂 ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

ah merde

bit.get()
Log.e(getString(R.string.log_tag),user.image)
val bit = BitmapGetterApi.download("https://raw.githubusercontent.com/Ashwinvalento/cartoon-avatar/master/lib/images/male/45.png")
bit.get(10, TimeUnit.SECONDS)
Copy link
Collaborator

Choose a reason for hiding this comment

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

the user image will be displayed during 10 seconds? isnt it a lot?

Copy link
Owner Author

Choose a reason for hiding this comment

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

No the 10 sec is the timeout to get the image. Indeed it is a magic number for the moment, but I may set it a global var for all async timeout and should choose the value later

Copy link
Collaborator

Choose a reason for hiding this comment

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

got you!

val bit = BitmapGetterApi.download("https://" + user.image)
bit.get()
Log.e(getString(R.string.log_tag),user.image)
val bit = BitmapGetterApi.download("https://raw.githubusercontent.com/Ashwinvalento/cartoon-avatar/master/lib/images/male/45.png")
Copy link
Collaborator

Choose a reason for hiding this comment

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

something to think about...

There are three options about profile images:

  1. We save the default image link in every profile in firebase.
  2. We save an image in our app
  3. We upload the picture from github every time (as you do)

We use profile picture in scoreboard, user search and in a profile account. If we take scoreboard, there might be a lot of profiles without the image, maybe it would be better if each of the profile has a default image, so we dont do extra check and upload image your way. Or it would be better to have an image locally, since it is same and we dont upload your way every time.

Copy link
Owner Author

Choose a reason for hiding this comment

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

yes we will see and try to solve this issue. Currently this is just a random image to test the display. I will rework it in part 2. There was issue with the database and account code that I will solve in part 2.

@MaximeZmt
Copy link
Owner Author

Thank you for your changes! There are several issues I ave addressed in the comments, can you respond to them? Thanks!

General comment, we should redirect user to the profile account after the user created the account. Right now, the user created account, automatically logged in, and then it is not redirected to profile account. You press go back, and the login is not displayed in the bottom of welcome page. It is resetted apparently.

Yes It will be done in the part 2 the following week, it is part of the rework

@codeclimate
Copy link

codeclimate bot commented Apr 18, 2022

Code Climate has analyzed commit d45b7df and detected 1 issue on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 1

The test coverage on the diff in this pull request is 84.2% (80% is the threshold).

This pull request will bring the total coverage in the repository to 87.9% (-0.8% change).

View more on Code Climate.

@kamilababayeva
Copy link
Collaborator

Thank you for replying to my comments! Approved!

@MaximeZmt MaximeZmt merged commit 40104f0 into main Apr 18, 2022
@MaximeZmt MaximeZmt deleted the maximezmt/fixpref branch April 18, 2022 20:47
@MaximeZmt MaximeZmt linked an issue Apr 18, 2022 that may be closed by this pull request
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
actual: 10h actual time to fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Part 1 of Update Score + Refactor Fix account
3 participants