I get this error when using onResetPasswordLink
Accounts.onResetPasswordLink was called more than once. Only one callback added will be executed
My code is inside reset.js, The code is following socially app style for angular1
import angular from 'angular';
import angularMeteor from 'angular-meteor';
import uiRouter from 'angular-ui-router';
//import ngPassword from 'angular-password';
import { Meteor } from 'meteor/meteor';
import { Accounts } from 'meteor/accounts-base';
import template from './reset.html';
import { name as Login } from '../login/login';
class Reset {
constructor($scope, $reactive, $state, $stateParams) {
'ngInject';
this.$state = $state;
$reactive(this).attach($scope);
//get token value from the url route
var resetToken = $stateParams.token;
var doneCallback;
if($stateParams.token != '')
{
Accounts.onResetPasswordLink(function (token, done) {
resetToken = $stateParams.token;
console.log(resetToken);
doneCallback = done;
});
}
this.credentials = {
newPassword: '',
reset: resetToken
};
this.error = '';
}
//
resetPassword() {
if(this.newPassword === this.confirmPassword)
{
Accounts.resetPassword(
resetToken, this. newPassword,
function (error) {
if (error) {
this.error = error;
}
else {
this.$state.go('login');
if (doneCallback)
doneCallback();
}
});
}
else
{
this.error = "Passwords do not match";
}
}
}
const name = 'reset';
// create a module
export default angular.module(name, [
angularMeteor,
uiRouter//,
// ngPassword
])
.component(name, {
template,
controllerAs: name,
controller: Reset
})
.config(config);
function config($stateProvider) {
'ngInject';
$stateProvider.state('reset', {
url: '/reset/:token',
template: '<reset></reset>'
});
}
My queestion is , what is the right way to use Accounts.onResetPasswordLink, where to place the code etc…
Thanks,
Remya