ciaranj / connect-auth

Authentication middleware for connect.
MIT License
813 stars 114 forks source link

Added support for offline access to the google oauth2 strategy #124

Closed ozkatz closed 11 years ago

ozkatz commented 11 years ago

Basically, 2 additions were made to the google2 strategy:

  1. expose an option to request for offline access
  2. save an expiry date to the session so that we could regenerate the access token before it expires (required for offline use).
ozkatz commented 11 years ago

Hi, sure - the double negation is just safe type-coercion to a boolean. regarding that +, It's a little shortcut to convert a date object into a timestamp.

I'd be of course happy to change any of these if they do not comply the project's style guidelines.

ciaranj commented 11 years ago

Was just making sure for the type-coercion, the + trick I did not know, is that ECMA5 or something ?

ozkatz commented 11 years ago

nope, it's actually the + unary operator. In javascript if you use + before any variable, it will actually coerce it to a number. For example, + "3" will work the same way.

ciaranj commented 11 years ago

;) I knew it was the + unary operator, what I didn't know was that using it like that would automatically call 'valueOf' on a field thats pretty neat, thank you! :)

ozkatz commented 11 years ago

Sure, happy to see my pull request had such a positive side effect :)

ciaranj commented 11 years ago

;) Always nice to learn something. (Thank you)