heecheon92 / Android-Project

Local Event App
0 stars 0 forks source link

LoginStatus or Token? Login Persistance! #4

Open MoonWolf125 opened 5 years ago

MoonWolf125 commented 5 years ago

One of the major issues that gets overlooked is that of tracking a login. Does the user need to be logged in every time the app is opened, logged out every time the app is closed, or only when the user chooses to log out? This is part of the process of creating an application, and was outlined in the challenge document as Login page should only show when a user has not yet logged in.

Unfortunately, there is an error in your application that forces the user to log in every time the application is terminated and reopened. This is due in part to the user of a second preference called loginStatus, the issue here is that you already have a preference called token that signifies when a user has logged in. If a user is successfully logged in they obtain a token, and this token can not only be used to obtain the data, but also as a representation for a loginStatus. Using the token instead of a loginStatus to track a users validity is common place in development as it cuts down on duplicated code and the number of preferences or attributes.

https://github.com/heecheon92/Android-Project/blob/a05d23c117f810ca2ff297a08d27d7d918636451/FargoEventProject/app/src/main/java/activity/LoginActivity.java#L77 https://github.com/heecheon92/Android-Project/blob/a05d23c117f810ca2ff297a08d27d7d918636451/FargoEventProject/app/src/main/java/activity/MainActivity.java#L73 https://github.com/heecheon92/Android-Project/blob/a05d23c117f810ca2ff297a08d27d7d918636451/FargoEventProject/app/src/main/java/activity/MainActivity.java#L181-L197 (This method is also public because of the XML onClick attribute when it should be private)

heecheon92 commented 5 years ago

Just fixed it. Thanks for your advice. I will push soon.