Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

klark-js-plugins

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

klark-js-plugins - npm Package Compare versions

Comparing version 1.0.13 to 1.0.14

plugins/routers/authorize/reset-password-email-tmp.module.js

0

.vscode/launch.json

@@ -0,0 +0,0 @@ {

{
"vsicons.presets.angular": false
}

2

package.json
{
"name": "klark-js-plugins",
"version": "1.0.13",
"version": "1.0.14",
"description": "Plugin modules for KlarkJS",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -0,0 +0,0 @@ 'use strict';

@@ -0,0 +0,0 @@ 'use strict';

@@ -0,0 +0,0 @@ 'use strict';

@@ -0,0 +0,0 @@ 'use strict';

@@ -0,0 +0,0 @@ 'use strict';

@@ -0,0 +0,0 @@ 'use strict';

@@ -0,0 +0,0 @@ 'use strict';

@@ -0,0 +0,0 @@ 'use strict';

@@ -9,2 +9,3 @@ 'use strict';

krkRoutersAuthorizeVerifyAccountEmailTmpl,
krkRoutersAuthorizeResetPasswordEmailTmpl,
krkNotificationsEmail,

@@ -73,2 +74,9 @@ krkMiddlewareResponse,

app.post('/' + config.apiUrlPrefix + '/authorize/resetPassword', [
krkMiddlewarePermissions.check('FREE'),
middlewareResetPasswordValidator,
middlewareResetPasswordController,
krkMiddlewareResponse.success
]);
function middlewareVerifyAccountParameterValidator(req, res, next) {

@@ -121,2 +129,14 @@ var validationOpts = [

function middlewareResetPasswordValidator(req, res, next) {
var validationOpts = [
{path: 'email', value: req.body.email, onValidate: v => res.locals.params.email = v}
];
krkParameterValidator.modelPartialValidator(krkModelsUser, validationOpts)
.then(function() { return next(); })
.catch(function(reason) {
res.locals.errors.add('INVALID_PARAMS', reason);
next(true);
});
}
function middlewareSignUpController(req, res, next) {

@@ -251,4 +271,53 @@ q.promisify(function(cb) { return $crypto.randomBytes(32, cb); })

}
function middlewareResetPasswordController(req, res, next) {
krkModelsUser.findOne({email: res.locals.params.email})
.catch(function(reason) {
res.locals.errors.add('DB_ERROR', reason);
return next(true);
})
.then(user => {
if (!user) {
return next();
}
q.resolve()
.then(() => ({
user,
token: $crypto.randomBytes(8)
}))
.then(function({user, token}) {
user.password = token.toString('hex');
return user.save();
})
.catch(function(reason) {
res.locals.errors.add('DB_ERROR', reason.errors || reason);
next(true);
})
.then(function(user) {
res.locals.data = user.getSafely();
var emailTemplate = krkRoutersAuthorizeResetPasswordEmailTmpl.template({
password: user.password,
user: user,
name: config.name,
appUrl: config.appUrl
});
return krkNotificationsEmail.send(emailTemplate, {
EMAIL_SMTP: config.EMAIL_SMTP,
EMAIL_NAME: config.EMAIL_NAME,
EMAIL_ADDRESS: config.EMAIL_ADDRESS
})
.catch(function(reason) {
res.locals.errors.add('EMAIL_FAIL', reason.errors || reason);
next(true);
});
})
.catch(function(reason) {
res.locals.errors.add('UNEXPECTED', reason.errors || reason);
next(true);
})
.then(function() { return next(); });
})
}
}
});

@@ -0,0 +0,0 @@ 'use strict';

@@ -0,0 +0,0 @@ 'use strict';

@@ -0,0 +0,0 @@ # klark plugins

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc