larvalabs / breaker

Chat rooms for subreddits.
http://www.breakerapp.com
20 stars 3 forks source link

Add login to mobile app #51

Open megamattron opened 8 years ago

megamattron commented 8 years ago

The new mobile app login path is described in #49 and was added in 1136e4c - basically it allows for a separate login path that redirects back to a mobile app URL scheme with a special login access token for the app. We now need to support storing and using this access token in the app. So the following things need to happen:

  1. If no access code is in storage, show a welcome page with a login button.
  2. When the login button is pressed open a browser (or show a webview overlay, not sure which one is best) to http://www.breakerapp.com/application/startAuthForMobileApp - this will run through the login process in the browser and eventually redirect to breaker://auth/[access_code]
  3. Configure app to intercept that URL scheme (or if you decide to use the webview, watch the requests that are loaded in the webview for a URL of that type - actually the webview might be a better idea rather than trusting the system browser) and parse out the access code and store it in the app's local storage.
  4. For every request to the server afterwards include the http header "X-BreakerAccessCode: [access_code_that_you_stored_above]" - the server will then recognize the user that logged in automatically.