-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
41 changed files
with
2,507 additions
and
1,210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/frontend/vue.js | ||
/frontend/app.js | ||
*~ | ||
*# | ||
.DS_STORE | ||
.netbeans | ||
nbproject | ||
.idea | ||
.node_history | ||
dump.rdb | ||
|
||
npm-debug.log | ||
lib-cov | ||
*.seed | ||
*.log | ||
*.out | ||
*.pid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"extends": "standard", | ||
"globals": { | ||
"localStorage": true, | ||
"alert": true, | ||
"sails": true, | ||
"node": true, | ||
"User": true, | ||
"_": true, | ||
"Vue": true | ||
}, | ||
"rules": { | ||
"quotes": [2, "double"], | ||
"semi": [2, "always"], | ||
"no-inner-declarations": 0, | ||
"no-throw-literal": 0 | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,5 @@ | |
*/ | ||
|
||
module.exports = { | ||
|
||
|
||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,38 @@ | ||
module.exports = { | ||
friendlyName: "Logout", | ||
|
||
description: "Log out of this app.", | ||
|
||
friendlyName: 'Logout', | ||
|
||
|
||
description: 'Log out of this app.', | ||
|
||
|
||
extendedDescription: | ||
`This action deletes the \`req.session.userId\` key from the session of the requesting user agent. | ||
extendedDescription: `This action deletes the \`req.session.userId\` key from the session of the requesting user agent. | ||
Actual garbage collection of session data depends on this app's session store, and | ||
potentially also on the [TTL configuration](https://sailsjs.com/docs/reference/configuration/sails-config-session) | ||
you provided for it. | ||
Note that this action does not check to see whether or not the requesting user was | ||
actually logged in. (If they weren't, then this action is just a no-op.)`, | ||
|
||
|
||
exits: { | ||
|
||
success: { | ||
description: 'The requesting user agent has been successfully logged out.' | ||
description: "The requesting user agent has been successfully logged out." | ||
}, | ||
|
||
redirect: { | ||
description: 'The requesting user agent looks to be a web browser.', | ||
extendedDescription: 'After logging out from a web browser, the user is redirected away.', | ||
responseType: 'redirect' | ||
description: "The requesting user agent looks to be a web browser.", | ||
extendedDescription: | ||
"After logging out from a web browser, the user is redirected away.", | ||
responseType: "redirect" | ||
} | ||
|
||
}, | ||
|
||
|
||
fn: async function () { | ||
|
||
// Clear the `userId` property from this session. | ||
delete this.req.session.userId; | ||
|
||
// Then finish up, sending an appropriate response. | ||
// > Under the covers, this persists the now-logged-out session back | ||
// > to the underlying session store. | ||
if (!this.req.wantsJSON) { | ||
throw {redirect: '/login'}; | ||
throw { redirect: "/login" }; | ||
} | ||
|
||
} | ||
|
||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,85 @@ | ||
module.exports = { | ||
friendlyName: "Update billing card", | ||
|
||
|
||
friendlyName: 'Update billing card', | ||
|
||
|
||
description: 'Update the credit card for the logged-in user.', | ||
|
||
description: "Update the credit card for the logged-in user.", | ||
|
||
inputs: { | ||
|
||
stripeToken: { | ||
type: 'string', | ||
example: 'tok_199k3qEXw14QdSnRwmsK99MH', | ||
description: 'The single-use Stripe Checkout token identifier representing the user\'s payment source (i.e. credit card.)', | ||
extendedDescription: 'Omit this (or use "") to remove this user\'s payment source.', | ||
type: "string", | ||
example: "tok_199k3qEXw14QdSnRwmsK99MH", | ||
description: | ||
"The single-use Stripe Checkout token identifier representing the user's payment source (i.e. credit card.)", | ||
extendedDescription: | ||
"Omit this (or use \"\") to remove this user's payment source.", | ||
whereToGet: { | ||
description: 'This Stripe.js token is provided to the front-end (client-side) code after completing a Stripe Checkout or Stripe Elements flow.' | ||
description: | ||
"This Stripe.js token is provided to the front-end (client-side) code after completing a Stripe Checkout or Stripe Elements flow." | ||
} | ||
}, | ||
|
||
billingCardLast4: { | ||
type: 'string', | ||
example: '4242', | ||
description: 'Omit if removing card info.', | ||
whereToGet: { description: 'Credit card info is provided by Stripe after completing the checkout flow.' } | ||
type: "string", | ||
example: "4242", | ||
description: "Omit if removing card info.", | ||
whereToGet: { | ||
description: | ||
"Credit card info is provided by Stripe after completing the checkout flow." | ||
} | ||
}, | ||
|
||
billingCardBrand: { | ||
type: 'string', | ||
example: 'visa', | ||
description: 'Omit if removing card info.', | ||
whereToGet: { description: 'Credit card info is provided by Stripe after completing the checkout flow.' } | ||
type: "string", | ||
example: "visa", | ||
description: "Omit if removing card info.", | ||
whereToGet: { | ||
description: | ||
"Credit card info is provided by Stripe after completing the checkout flow." | ||
} | ||
}, | ||
|
||
billingCardExpMonth: { | ||
type: 'string', | ||
example: '08', | ||
description: 'Omit if removing card info.', | ||
whereToGet: { description: 'Credit card info is provided by Stripe after completing the checkout flow.' } | ||
type: "string", | ||
example: "08", | ||
description: "Omit if removing card info.", | ||
whereToGet: { | ||
description: | ||
"Credit card info is provided by Stripe after completing the checkout flow." | ||
} | ||
}, | ||
|
||
billingCardExpYear: { | ||
type: 'string', | ||
example: '2023', | ||
description: 'Omit if removing card info.', | ||
whereToGet: { description: 'Credit card info is provided by Stripe after completing the checkout flow.' } | ||
}, | ||
|
||
type: "string", | ||
example: "2023", | ||
description: "Omit if removing card info.", | ||
whereToGet: { | ||
description: | ||
"Credit card info is provided by Stripe after completing the checkout flow." | ||
} | ||
} | ||
}, | ||
|
||
|
||
fn: async function (inputs) { | ||
|
||
// Add, update, or remove the default payment source for the logged-in user's | ||
// customer entry in Stripe. | ||
var stripeCustomerId = await sails.helpers.stripe.saveBillingInfo.with({ | ||
stripeCustomerId: this.req.me.stripeCustomerId, | ||
token: inputs.stripeToken || '', | ||
}).timeout(5000).retry(); | ||
var stripeCustomerId = await sails.helpers.stripe.saveBillingInfo | ||
.with({ | ||
stripeCustomerId: this.req.me.stripeCustomerId, | ||
token: inputs.stripeToken || "" | ||
}) | ||
.timeout(5000) | ||
.retry(); | ||
|
||
// Update (or clear) the card info we have stored for this user in our database. | ||
// > Remember, never store complete card numbers-- only the last 4 digits + expiration! | ||
// > Storing (or even receiving) complete, unencrypted card numbers would require PCI | ||
// > compliance in the U.S. | ||
await User.updateOne({ id: this.req.me.id }) | ||
.set({ | ||
await User.updateOne({ id: this.req.me.id }).set({ | ||
stripeCustomerId, | ||
hasBillingCard: inputs.stripeToken ? true : false, | ||
billingCardBrand: inputs.stripeToken ? inputs.billingCardBrand : '', | ||
billingCardLast4: inputs.stripeToken ? inputs.billingCardLast4 : '', | ||
billingCardExpMonth: inputs.stripeToken ? inputs.billingCardExpMonth : '', | ||
billingCardExpYear: inputs.stripeToken ? inputs.billingCardExpYear : '' | ||
hasBillingCard: !!inputs.stripeToken, | ||
billingCardBrand: inputs.stripeToken ? inputs.billingCardBrand : "", | ||
billingCardLast4: inputs.stripeToken ? inputs.billingCardLast4 : "", | ||
billingCardExpMonth: inputs.stripeToken ? inputs.billingCardExpMonth : "", | ||
billingCardExpYear: inputs.stripeToken ? inputs.billingCardExpYear : "" | ||
}); | ||
|
||
} | ||
|
||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,23 @@ | ||
module.exports = { | ||
friendlyName: "Update password", | ||
|
||
|
||
friendlyName: 'Update password', | ||
|
||
|
||
description: 'Update the password for the logged-in user.', | ||
|
||
description: "Update the password for the logged-in user.", | ||
|
||
inputs: { | ||
|
||
password: { | ||
description: 'The new, unencrypted password.', | ||
example: 'abc123v2', | ||
description: "The new, unencrypted password.", | ||
example: "abc123v2", | ||
required: true | ||
} | ||
|
||
}, | ||
|
||
|
||
fn: async function (inputs) { | ||
|
||
// Hash the new password. | ||
var hashed = await sails.helpers.passwords.hashPassword(inputs.password); | ||
|
||
// Update the record for the logged-in user. | ||
await User.updateOne({ id: this.req.me.id }) | ||
.set({ | ||
await User.updateOne({ id: this.req.me.id }).set({ | ||
password: hashed | ||
}); | ||
|
||
} | ||
|
||
|
||
}; |
Oops, something went wrong.