-
Notifications
You must be signed in to change notification settings - Fork 0
Login to the server #82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
mariana0412
commented
Nov 8, 2024
- Implemented login to the TDEI server
- Implemented saving received token and its expiration date to Keychain for using in future requests
- Added checking if token is present in Keychain and valid in order to decide which screen user should see first - Login or Setup
|
|
||
| init() { | ||
| let isTokenValid = keychainService.isTokenValid() | ||
| _isAuthenticated = State(initialValue: isTokenValid) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So mostly, I do not see a problem with this kind of initialization for this context, despite its misgivings given in:
https://stackoverflow.com/questions/56691630/swiftui-state-var-initialization-issue
More specifically: https://stackoverflow.com/a/71247040
I wonder if there would come a situation where this initialization could cause problems. Most likely it shouldn't.
I'll just keep it in mind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just as a note, we don't have a problem with this way to setting the State because the struct IOSAccessAssessment does not have any dependencies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this article does mention that this is bad practice, since we are accommodating what may lead to potentially inconsistent behavior:
https://www.swiftcraft.io/articles/how-to-initialize-state-inside-the-views-init-
| } | ||
| .padding() | ||
| .navigationBarTitle("Setup View", displayMode: .inline) | ||
| .navigationBarBackButtonHidden(true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Later we should have a logout feature as well.
|
Error message: Seems to be JSON error, even if the password is the incorrect one. |
|
Aside from my comments it looks good to me as a first PR for the login page. |
|
This is great! |