mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-22 23:23:54 +08:00
commit 64938016f6ffbf366a220e7abd9af6f7a4cb478b Author: Ben Gotow <bengotow@gmail.com> Date: Sun Oct 4 16:42:38 2015 -0700 Don't allow people to double click the token check button, make requests take at least 400msec commit e548f3ee449c676a813c5630f1624963872ed6e6 Merge: 3350b91 e4b4933 Author: Ben Gotow <bengotow@gmail.com> Date: Sun Oct 4 16:39:56 2015 -0700 Merge branch 'token-auth' of github.com:nylas/N1 into token-auth # Conflicts: # internal_packages/onboarding/lib/token-auth-page.cjsx commit 3350b917449c29299fa078d59a4a5a9339fdf29b Author: Ben Gotow <bengotow@gmail.com> Date: Sun Oct 4 16:38:52 2015 -0700 Improve a few error states, adding "checking" state when checking token commit e4b49334cbf59145d9bdd955d35636f16a7c4924 Author: EthanBlackburn <ethan@nylas.com> Date: Sun Oct 4 16:21:39 2015 -0700 Correct retry behavior commit 11cd9a75b2a1ca0f4347160df93815743909ccea Author: EthanBlackburn <ethan@nylas.com> Date: Sat Oct 3 18:06:55 2015 -0700 Removed old auth token variable commit afe451cd70de528def3443d8b373fd24f4aa5cde Author: EthanBlackburn <ethan@nylas.com> Date: Sat Oct 3 16:08:12 2015 -0700 Added token auth page
85 lines
2.8 KiB
CoffeeScript
85 lines
2.8 KiB
CoffeeScript
React = require 'react'
|
|
_ = require 'underscore'
|
|
{RetinaImg} = require 'nylas-component-kit'
|
|
{EdgehillAPI, Utils} = require 'nylas-exports'
|
|
|
|
OnboardingActions = require './onboarding-actions'
|
|
Providers = require './account-types'
|
|
url = require 'url'
|
|
|
|
class AccountChoosePage extends React.Component
|
|
@displayName: "AccountChoosePage"
|
|
|
|
constructor: (@props) ->
|
|
@state =
|
|
email: ""
|
|
provider: ""
|
|
|
|
componentWillUnmount: ->
|
|
@_usub?()
|
|
|
|
render: =>
|
|
<div className="page account-choose">
|
|
<div className="quit" onClick={ -> OnboardingActions.closeWindow() }>
|
|
<RetinaImg name="onboarding-close.png" mode={RetinaImg.Mode.ContentPreserve}/>
|
|
</div>
|
|
|
|
<RetinaImg url="nylas://onboarding/assets/nylas-pictographB@2x.png" mode={RetinaImg.Mode.ContentPreserve} style={zoom: 0.29, opacity: 0.55} className="logo"/>
|
|
|
|
<div className="caption" style={marginTop: 15, marginBottom:20}>Select your email provider</div>
|
|
|
|
{@_renderProviders()}
|
|
|
|
</div>
|
|
|
|
_renderProviders: ->
|
|
return Providers.map (provider) =>
|
|
<div className={"provider "+provider.name} key={provider.name} onClick={=>@_onChooseProvider(provider)}>
|
|
|
|
<div className="icon-container">
|
|
<RetinaImg name={provider.icon} mode={RetinaImg.Mode.ContentPreserve} className="icon"/>
|
|
</div>
|
|
<span className="provider-name">{provider.displayName}</span>
|
|
</div>
|
|
|
|
_renderError: ->
|
|
if @state.error
|
|
<div className="alert alert-danger" role="alert">
|
|
{@state.error}
|
|
</div>
|
|
else <div></div>
|
|
|
|
_onEmailChange: (event) =>
|
|
@setState email: event.target.value
|
|
|
|
_onChooseProvider: (provider) =>
|
|
if provider.name is 'gmail'
|
|
# Show the "Sign in to Gmail" prompt for a moment before actually bouncing
|
|
# to Gmail. (400msec animation + 200msec to read)
|
|
_.delay =>
|
|
@_onBounceToGmail(provider)
|
|
, 600
|
|
OnboardingActions.moveToPage("account-settings", {provider})
|
|
|
|
_onBounceToGmail: (provider) =>
|
|
provider.clientKey = Utils.generateTempId()[6..]+'-'+Utils.generateTempId()[6..]
|
|
shell = require 'shell'
|
|
googleUrl = url.format({
|
|
protocol: 'https'
|
|
host: 'accounts.google.com/o/oauth2/auth'
|
|
query:
|
|
response_type: 'code'
|
|
state: provider.clientKey
|
|
client_id: '372024217839-cdsnrrqfr4d6b4gmlqepd7v0n0l0ip9q.apps.googleusercontent.com'
|
|
redirect_uri: "#{EdgehillAPI.APIRoot}/oauth/google/callback"
|
|
access_type: 'offline'
|
|
scope: 'https://www.googleapis.com/auth/userinfo.email \
|
|
https://www.googleapis.com/auth/userinfo.profile \
|
|
https://mail.google.com/ \
|
|
https://www.google.com/m8/feeds \
|
|
https://www.googleapis.com/auth/calendar'
|
|
approval_prompt: 'force'
|
|
})
|
|
shell.openExternal(googleUrl)
|
|
|
|
module.exports = AccountChoosePage
|