mirror of
https://github.com/fleetdm/fleet
synced 2026-05-22 08:28:52 +00:00
* rename dir * no need to install website or docs from npm At some point, would also be nice to be able to exclude assets/ as well, and to only install a pre-built version of Fleet's frontend code * Bring in fleetdm.com website From https://github.com/fleetdm/fleetdm.com as of https://github.com/fleetdm/fleetdm.com/releases/tag/v0.0.21 * add procfile for heroku Using https://github.com/timanovsky/subdir-heroku-buildpack * avoid getting anybody's hopes up * Create deploy-fleet-website.yml (#82) * Create deploy-fleet-website.yml * Update deploy-fleet-website.yml * Update deploy-fleet-website.yml * Update deploy-fleet-website.yml * update pjs with SPDX-like license expressions. also fix repo URL and remove package lock * Update deploy-fleet-website.yml * Update deploy-fleet-website.yml * remove dummy uri * Dissect deploy script * Update deploy-fleet-website.yml * workaround for eslintrc nesting issue * lint fixes * forgot the .js * add per-commit git config * Update deploy-fleet-website.yml * might as well remove that * cleanup * connect w/ heroku app and have it actually push * fix bug I introduced in578a1a01ff* Update deploy-fleet-website.yml * Update deploy-fleet-website.yml * Update deploy-fleet-website.yml * Update deploy-fleet-website.yml * the beauty, the glory, of javascript * GH actions don't like "\n" * Update deploy-fleet-website.yml * restore \n chars from0d45e568f6hoping I was wrong in0d45e568f6but see also https://github.community/t/what-is-the-correct-character-escaping-for-workflow-command-values-e-g-echo-xxxx/118465/5 * Update deploy-fleet-website.yml * Update deploy-fleet-website.yml * Update deploy-fleet-website.yml * Update deploy-fleet-website.yml * Update deploy-fleet-website.yml * Update deploy-fleet-website.yml * Update deploy-fleet-website.yml * Update deploy-fleet-website.yml * Update deploy-fleet-website.yml * Update deploy-fleet-website.yml * Update deploy-fleet-website.yml * Update deploy-fleet-website.yml * rename script to prevent duplicate building * Configure the real website * clean up * a test of the deploy workflow * add handbook to npmignore * I guess you could call this fixing a typo * point workflow at master branch * now clearly bogus: this completely unused version string
121 lines
3.6 KiB
JavaScript
Vendored
121 lines
3.6 KiB
JavaScript
Vendored
module.exports = {
|
|
|
|
|
|
friendlyName: 'Signup',
|
|
|
|
|
|
description: 'Sign up for a new user account.',
|
|
|
|
|
|
extendedDescription:
|
|
`This creates a new user record in the database, signs in the requesting user agent
|
|
by modifying its [session](https://sailsjs.com/documentation/concepts/sessions), and
|
|
(if emailing with Mailgun is enabled) sends an account verification email.
|
|
|
|
If a verification email is sent, the new user's account is put in an "unconfirmed" state
|
|
until they confirm they are using a legitimate email address (by clicking the link in
|
|
the account verification message.)`,
|
|
|
|
|
|
inputs: {
|
|
|
|
emailAddress: {
|
|
required: true,
|
|
type: 'string',
|
|
isEmail: true,
|
|
description: 'The email address for the new account, e.g. [email protected].',
|
|
extendedDescription: 'Must be a valid email address.',
|
|
},
|
|
|
|
password: {
|
|
required: true,
|
|
type: 'string',
|
|
maxLength: 200,
|
|
example: 'passwordlol',
|
|
description: 'The unencrypted password to use for the new account.'
|
|
},
|
|
|
|
fullName: {
|
|
required: true,
|
|
type: 'string',
|
|
example: 'Frida Kahlo de Rivera',
|
|
description: 'The user\'s full name.',
|
|
}
|
|
|
|
},
|
|
|
|
|
|
exits: {
|
|
|
|
success: {
|
|
description: 'New user account was created successfully.'
|
|
},
|
|
|
|
invalid: {
|
|
responseType: 'badRequest',
|
|
description: 'The provided fullName, password and/or email address are invalid.',
|
|
extendedDescription: 'If this request was sent from a graphical user interface, the request '+
|
|
'parameters should have been validated/coerced _before_ they were sent.'
|
|
},
|
|
|
|
emailAlreadyInUse: {
|
|
statusCode: 409,
|
|
description: 'The provided email address is already in use.',
|
|
},
|
|
|
|
},
|
|
|
|
|
|
fn: async function ({emailAddress, password, fullName}) {
|
|
|
|
var newEmailAddress = emailAddress.toLowerCase();
|
|
|
|
// Build up data for the new user record and save it to the database.
|
|
// (Also use `fetch` to retrieve the new ID so that we can use it below.)
|
|
var newUserRecord = await User.create(_.extend({
|
|
fullName,
|
|
emailAddress: newEmailAddress,
|
|
password: await sails.helpers.passwords.hashPassword(password),
|
|
tosAcceptedByIp: this.req.ip
|
|
}, sails.config.custom.verifyEmailAddresses? {
|
|
emailProofToken: await sails.helpers.strings.random('url-friendly'),
|
|
emailProofTokenExpiresAt: Date.now() + sails.config.custom.emailProofTokenTTL,
|
|
emailStatus: 'unconfirmed'
|
|
}:{}))
|
|
.intercept('E_UNIQUE', 'emailAlreadyInUse')
|
|
.intercept({name: 'UsageError'}, 'invalid')
|
|
.fetch();
|
|
|
|
// If billing feaures are enabled, save a new customer entry in the Stripe API.
|
|
// Then persist the Stripe customer id in the database.
|
|
if (sails.config.custom.enableBillingFeatures) {
|
|
let stripeCustomerId = await sails.helpers.stripe.saveBillingInfo.with({
|
|
emailAddress: newEmailAddress
|
|
}).timeout(5000).retry();
|
|
await User.updateOne({id: newUserRecord.id})
|
|
.set({
|
|
stripeCustomerId
|
|
});
|
|
}
|
|
|
|
// Store the user's new id in their session.
|
|
this.req.session.userId = newUserRecord.id;
|
|
|
|
if (sails.config.custom.verifyEmailAddresses) {
|
|
// Send "confirm account" email
|
|
await sails.helpers.sendTemplateEmail.with({
|
|
to: newEmailAddress,
|
|
subject: 'Please confirm your account',
|
|
template: 'email-verify-account',
|
|
templateData: {
|
|
fullName,
|
|
token: newUserRecord.emailProofToken
|
|
}
|
|
});
|
|
} else {
|
|
sails.log.info('Skipping new account email verification... (since `verifyEmailAddresses` is disabled)');
|
|
}
|
|
|
|
}
|
|
|
|
};
|