Skip to content
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

feat(auth): use WebView for authentication #323

Merged
merged 16 commits into from
Sep 23, 2017
Merged

feat(auth): use WebView for authentication #323

merged 16 commits into from
Sep 23, 2017

Conversation

machour
Copy link
Member

@machour machour commented Sep 11, 2017

Closes #109 and #221

Rather than using another library to handle Android, I went ahead and used the WebView component from ReactNative. This seems to be working fine for me on iOS Simulator and my Android Device.

I would really love to have a thorough review of my code, as I feel I've kinda abused the view system here. (and it's the app entry point, so it's a really critical change 😆 )

Copy link
Member

@lex111 lex111 left a comment

Choose a reason for hiding this comment

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

Really nice work 👍

@machour
Copy link
Member Author

machour commented Sep 11, 2017

Thanks! Although it still seems buggy on my device, I sometime find myself logged in with an empty events tab and nothing clickable. So still WIP.

Copy link
Member

@housseindjirdeh housseindjirdeh left a comment

Choose a reason for hiding this comment

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

First and foremost, this is such a great job @machour it's amazing 😍 You've made it feel like a separate window isn't even opening by rendering a WebView with a section underneath:

image

I know this is a WIP progress but here's a few things I noticed. Noticing an issue on the simulator however with the navigator consistently firing and navigating to Main and I'm not sure why 🤔

sep-11-2017 12-02-16

When I reload the app, I notice just like you mentioned: a logged in events tab with nothing clickable and showing.

Another thing is the Cancel button you've included (which I think is just awesome :)). Unfortunately if I try to cancel while the loading step is firing it doesn't necessarily stop the call.

sep-11-2017 12-05-21

Notice how the original Welcome screen remains in the back as well? I love the new Preparing GitPoint screen you have so we'll have to:

  1. Make sure the cancel button isn't there (or disabled) when the call is being fired since the user can't necessarily cancel the call
  2. Remove the Welcome Screen entirely since we have this new intermediate step

OR you can just make sure that clicking sign in will navigate directly to the Welcome Screen and not rely on the webview anymore (happy to have it restyled to match your intermediate Preparing GitPoint screen.

height: '100%',
width: '100%',
textAlign: 'center',
backgroundColor: '#1f2327',
Copy link
Member

Choose a reason for hiding this comment

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

Let's put #1f2327 in the colors file. Can call it whatever you think sounds reasonable (githubDark or something if you like).

@machour
Copy link
Member Author

machour commented Sep 13, 2017

@housseindjirdeh I think I fixed the problem with iOS by using Linking only for Android.
I also disabled the cancel button when needed, revamped the Welcome screen to be consistant and cleaned up my UI mess.
Could you give it a new try?

@andrewda andrewda changed the title [wip] Webview for auth wip: feat(auth): use WebView for authentication Sep 13, 2017
onLoadEnd = e => {
const url = e.nativeEvent.url;

if (url === 'https://github.com/session') {
Copy link
Member

Choose a reason for hiding this comment

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

I'm just thinking out loud: can made a separate method, because this code line two times is used, then the meaning of this check will be more clear?

Copy link
Member Author

Choose a reason for hiding this comment

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

Great advice, thanks! Refactored here: c2c4d56

@machour machour changed the title wip: feat(auth): use WebView for authentication feat(auth): use WebView for authentication Sep 13, 2017
@machour
Copy link
Member Author

machour commented Sep 13, 2017

I went ahead and fixed #182 in this same PR by resetting the WebView's cookie as per @andrewda recommendation. The logout is now instantaneous (maybe even too quick 💭 )

I used https://github.com/joeferraro/react-native-cookies to clear the cookies, which needs some extra step in XCode and Android build, documented in their README. I didn't commit the ios/ and android/directories cause I had to tweak a lot of weird things to have a working environment in the same place. I'd rather have one of you guys with a cleaner environment do it when merging this PR.

@@ -4,6 +4,9 @@
export const en = {
auth: {
login: {
connectingToGitHub: 'Connecting to GitHub..',
preparingGitPoint: 'Preparing GitPoint..',
Copy link
Member

@andrewda andrewda Sep 14, 2017

Choose a reason for hiding this comment

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

Add another period to these: Connecting to GitHub... and Preparing GitPoint....

Copy link
Member

Choose a reason for hiding this comment

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

@machour and more you need to add new keys to other languages, otherwise there will be errors.

Copy link
Member Author

Choose a reason for hiding this comment

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

@andrewda thanks, fixed!
@lex111 currently if a string is missing, it's displayed with an error Missing translation for tr.auth.login.cancel. Isn't that good enough while working on master? Or should I introduce the keys in all language with the english sentence?

Copy link
Member

Choose a reason for hiding this comment

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

@machour yes, you need to add English sentences to all languages, just so that there are no such errors.

Copy link
Member Author

Choose a reason for hiding this comment

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

@lex111 done buddy! I think I'll tackle down i18n right after auth & markdown 😄

@@ -2,6 +2,9 @@
export const fr = {
auth: {
login: {
connectingToGitHub: 'Connexion à GitHub..',
preparingGitPoint: 'Configuration de GitPoint..',
Copy link
Member

Choose a reason for hiding this comment

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

Missing dot 😄

Copy link
Member Author

Choose a reason for hiding this comment

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

not in french ;)

Copy link
Member

Choose a reason for hiding this comment

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

Wow, I did not know 😃

@@ -236,6 +236,7 @@ class Login extends Component {
<View style={styles.container}>
<Modal
animationType="slide"
onRequestClose={() => null}
Copy link
Member

Choose a reason for hiding this comment

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

👍

@@ -623,6 +642,7 @@
isa = PBXGroup;
children = (
273F19201F1E1AD5004B4410 /* libCodePush.a */,
48F9DE9B1F6DB8C60064194C /* libCodePush.a */,
Copy link
Member Author

Choose a reason for hiding this comment

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

@housseindjirdeh not sure why Xcode added this line, you may want to have a closer look

@@ -1148,6 +1181,20 @@
remoteRef = 48F49F661F19026D0012FAD6 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
48F9DE9B1F6DB8C60064194C /* libCodePush.a */ = {
Copy link
Member Author

Choose a reason for hiding this comment

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

same here @housseindjirdeh

@machour
Copy link
Member Author

machour commented Sep 16, 2017

@housseindjirdeh @andrewda @lex111
I just cleaned my project and was able to include links in android/ and ios/ for react-native-cookies. I thing this PR is all set now.

I'd love to see this merged soon in order for it to be fully tested by everyone before making it to the next release 🙏

Copy link
Member

@housseindjirdeh housseindjirdeh left a comment

Choose a reason for hiding this comment

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

This works beautifully mate 😍

Signing out NOW works perfectly when tested on my simulator. Had this error however:

image

But cleaning and rebuilding in XCode fixed things 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants