Skip to content
This repository was archived by the owner on Jun 13, 2023. It is now read-only.

Added support for session token and user authentication. #60

Merged
merged 3 commits into from
Oct 26, 2016

Conversation

agordeev
Copy link
Contributor

Added using of sessionToken for both Connect and Subscribe messages. sessionToken is taken from PFUser.currentUser() directly and passes only if it's not nil.

Tested, works fine for me.

@ghost
Copy link

ghost commented Aug 21, 2016

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at [email protected]. Thanks!

@agordeev
Copy link
Contributor Author

Inspired by this issue: #40

@ghost ghost added the CLA Signed label Aug 21, 2016
@ghost
Copy link

ghost commented Aug 21, 2016

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@richardjrossiii
Copy link
Contributor

Sorry it's taken so long to get to this.

IIRC, the original reason I left out sending sessionToken, was that I couldn't come up with a good solution for logout occurring, or the current user changing in-between subscriptions.

One initial plan I had, was to have a single PFUser instance associated with a live query client, that could be passed on initialization (and the default client would use currentUser).

The issue with this, again, is logout. There's currently no way in the SDK to know when a user is logged out, and I had hoped that I would be able to invalidate all of the subscriptions when this occurred.

With that said, this is a great first step!

I've added a few more comments inline, that I'd like addressed before this gets merged.

@@ -23,7 +23,7 @@ public class Client: NSObject {
let clientKey: String?

var socket: SRWebSocket?
var userDisconnected = false
public var userDisconnected = false
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does this need to be made public - this only controls whether or not 'disconnect()' was explicitly called, and the person using the Client should know this already, no?

Copy link
Contributor Author

@agordeev agordeev Oct 15, 2016

Choose a reason for hiding this comment

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

I use this property in my own project to automatically reconnect to the socket after the Internet connection is available again. Otherwise I don't know any way to know whether the client is connected or not.

@flovilmart
Copy link
Contributor

@andrew8712 are you still up to take care of those nits so we can merge it and make it part of 1.1.1?

@agordeev
Copy link
Contributor Author

@flovilmart Looks like my fork is pretty outdated. Would you be able to merge it or you want me to merge the fork from master first? My project uses this fork, and it's not migrated to Swift 3, so I didn't update the fork too.

@flovilmart
Copy link
Contributor

You'll probably need to rebase and update to swift 3.

I'll let @richardjrossiii do the final review and merge as he had some concerns

@flovilmart
Copy link
Contributor

@andrew8712 we'll likely need to update to swift3, I could also add the support myself, but I don't like to take this good work for myself! So your call :)

Added using of sessionToken for both Connect and Subscribe messages. sessionToken is taken from PFUser.currentUser() directly and passes only if it's not nil.
@agordeev
Copy link
Contributor Author

@flovilmart Done. unfortunately, I couldn't test the changes on my project, as it's still not migrated to Swft 3.

@flovilmart
Copy link
Contributor

Awesome! I'll have a look later today!

@flovilmart
Copy link
Contributor

That's looking great! We probably want to add a notification to the iOS SDK to notify login/logout events and listen to that to automatically refresh the subscriptions.

@flovilmart flovilmart merged commit 7b32e74 into parse-community:master Oct 26, 2016
@agordeev
Copy link
Contributor Author

@flovilmart Agree, that case should be definitely handled.

@flovilmart
Copy link
Contributor

@andrew8712 wanna make a PR on the iOS SDK to notify user logins/logout events?

@agordeev
Copy link
Contributor Author

@flovilmart Parse iOS SDK is out of my scope at this moment :)

@flovilmart
Copy link
Contributor

alright I'Ll see what I can do then

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

Successfully merging this pull request may close these issues.

4 participants