Switch to being a website instead of a Chrome app.
Update our CNAME to be the more appropriate "prototype.useducky.com" when we
deploy.
Create a homepage and a non-onboarding page template. This mostly consisted of
setting up a header component and the associated styles, and then a logged-in
vs. guest flavor of said header, changing the links appropriately.
We also created a simple homepage that describes what Ducky is and does, and
gave a jumping-off point for it.
Stubbed out a basic links page, just to get an idea for what the homepage would
be like when a logged-in user navigated to the homepage (e.g., not the marketing
copy).
Updated our login page to _actually work_, and redirected it to the new URL for
the payment setup page.
Updated the payment page to actually create a subscription, and moved it from
/register/payment to just /payment.
Fixed a bug in our registration page that was looking for an invalid_form error
when it really meant an invalid_format error. Ooops. Also, updated it to point
to the new /payment endpoint instead of /register/payment.
Updated our router to use the new homepage, the new links page, and updated the
URL for the payment page.
Updated our button styles so they should all have the right font color, padding,
and border-radius, but could've potentially screwed something up. Oops.
Updated our backgrounds all over to have a transparent-y white background behind
the content, and a simple pattern for the rest of the body. Not sure how I feel
about it just yet, but I'm not going to keep futzing with it.
1 import app from 'ampersand-app'
4 import Sync from 'ampersand-sync'
5 import config from '../config'
7 const getRefresh = (opts, callback) => {
9 url: config.urlBase + '/auth/token',
12 'Content-Type': 'application/x-www-form-urlencoded',
13 'Authorization': 'Basic ' + btoa(config.clientID + ':' + config.clientSecret),
16 'grant_type': 'refresh_token',
17 'refresh_token': app.me.refresh_token
20 xhr(refreshOpts, function(err, resp, body) {
21 if (resp.statusCode != 200) {
22 callback(err, resp, body)
25 if (body && resp.headers['content-type'] == 'application/json') {
27 body = JSON.parse(body)
29 app.trigger('token:refreshError', body)
30 callback(err, resp, body)
33 if (body.access_token) {
36 app.trigger('token:refreshError', body)
38 callback(err, resp, body)
42 const shouldRefreshXHR = (err, resp, body) => {
43 if(body && resp.headers['Content-Type'] == 'application/json') {
45 body = JSON.parse(body)
50 if (resp.statusCode == 401 && body.errors && body.errors[0]
51 && body.errors[0].header == 'authorization' && body.errors[0].error == 'access_denied') {
57 const doRefreshXHR = (opts, callback) => {
59 getRefresh(opts, function(err, resp, body) {
60 if (body.access_token) {
61 opts.headers['Authorization'] = 'Bearer '+body.access_token
67 const refreshXHR = (opts, callback) => {
68 return xhr(opts, function(err, resp, body) {
69 if (opts.noRefresh || !shouldRefreshXHR(err, resp, body)) {
70 callback(err, resp, body)
73 doRefreshXHR(opts, callback)
78 const shouldRefreshSync = (resp) => {
79 if (resp && resp.errors && resp.errors[0]
80 && resp.errors[0].header == 'authorization' && resp.errors[0].error == 'access_denied') {
86 const doRefreshSync = (action, moc, opts) => {
88 getRefresh(opts, function(err, resp, body) {
89 if (body.access_token) {
90 Sync(action, moc, opts)
95 const refreshSync = (action, moc, opts) => {
96 const oldError = opts.error
97 opts.error = function(resp) {
98 if(opts.noRefresh || !shouldRefreshSync(resp)) {
102 doRefreshSync(action, moc, opts)
104 Sync(action, moc, opts)
112 export default refresh