Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function activateAccount (args) {
var credentials = {
token: args.token,
password: args.password
}
log.debug('Sending account activation request...')
return callServices('User.activateAccount', { arguments: credentials })
.then(function onSuccess (result) {
log.debug('Account activation request successful.')
// update session
return getSession().then(function(session){
if (session.isAuthenticated) log.debug('Activated user is logged in.')
return session
})
}, function onError (error) {
log.debug('Account activation failed.', error)
return Promise.reject(error)
})
}
}, function onSignUpError(error){
// denied
log.debug('API: Could not sign up using email "' + credentials.email + '".', error)
return Promise.reject(error)
})
}, function onError(error){
// denied
log.debug('API: requesting password reset failed.', error)
return Promise.reject(error)
})
.then(function onSuccess (session) {
log.debug('API: session data:\n', session)
// stream session object
sessionStream.next(session)
// return result
return session
}, function onError (error) {
log.debug('API: error receiving session data.', error)
export default function getSecretApiKey () {
log.debug('Sent API request reading secret key ...')
return callServices('Organization.read').then(function onSuccess (result) {
if (result.secretApiKey) {
log.debug('Received secret API key from API')
return result.secretApiKey
} else {
// user has no secret key yet: generate one
log.debug('User has no secret key. Sent request to generate one.')
return regenerateSecretApiKey()
}
}, function onError (error) {
log.debug('Error receiving secret API key')
return Promise.reject(error)
})
}
return callServices('Organization.generateSecretApiKey').then(function onSuccess(key) {
log.debug('API: Generating secret API key successful: ', key)
return key
}, function onReject(error) {
log.error('API: Error generating secret key.', error)
}, function onError (error) {
log.debug('Account activation failed.', error)
return Promise.reject(error)
})
}
export default function regenerateSecretApiKey () {
log.debug('Sending API request to generate secret API key ...')
return callServices('Organization.generateSecretApiKey').then(function onSuccess(key) {
log.debug('API: Generating secret API key successful: ', key)
return key
}, function onReject(error) {
log.error('API: Error generating secret key.', error)
return Promise.reject(error)
})
}