Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // global variable
- var resetQueryParameters = '';
- //CAPTURE TOKEN (QUERY PARAMS) FROM LINK
- app.get('/resetQuery/', function (req, res) {
- //SET THE TOKEN TO VARIABLE
- resetQueryParameters = req.query.token;
- r.db('myDB').table('Reset_Password').filter(r.row('auth_key').eq(req.query.token)).
- run(myConnection, function (err, cursor) {
- if (err) {
- return next(err);
- }
- cursor.toArray(function (err, result) {
- if (err) {
- throw err;
- } else {
- if (result.length > 0) {
- res.redirect(redirectResetPage);
- } else {
- res.redirect(redirectLoginPage);
- }
- return result;
- console.log("printing reset link from db.....", JSON.stringify(result, null, 2));
- }
- });
- });
- });
- function resetPassword(req, res, next) {
- console.log('reset password called from external link.....');
- nJwt.verify(resetQueryParameters, secretKey, function (err, verifiedJwt) {
- if (err) {
- console.log('reset token not valid...', err);
- } else {
- var params = {
- 'username': verifiedJwt.body.details,
- 'newPassword': req.params.newPassword
- };
- getApiResponse(resetURL, params, function (res1) {
- console.log('sending reset params to server...', params);
- if (res1.error) {
- console.log('Could not reset password......', res1.error);
- } else {
- console.log('reset password success.....');
- resetQueryParameters = '';
- res.json(res1);
- }
- });
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement