Reputation: 175
I'm using meteor Accounts package for user management. i want to implement forgot password functionality. for that i'm going to use Accounts.forgotPassword(options, [callback])
Here is my client side function to trigger forgot password
> forgetPassword = () => {
> let email = this.refs.email.value;
> Meteor.call('forgetPassword',email, function(err,list) {
> console.log(err);
> });
>}
Here is my server side function
forgetPassword: function(email){
Accounts.forgotPassword({email: email}, function(err) {
if (err) {
if (err.message === 'User not found [403]') {
console.log('This email does not exist.');
} else {
console.log('We are sorry but something went wrong.');
}
} else {
console.log('Email Sent. Check your mailbox.');
}
});
}
I'm getting below error while i call this functions
I20160517-21:33:53.292(5.5)? Exception while invoking method 'forgetPassword' Ty
peError: Object [object Object] has no method 'forgotPassword'
I20160517-21:33:53.293(5.5)? at [object Object].forgetPassword (meteor://?ap
p/webpack:///C:/wamp/www/avo_eth_v2.1/modules/TruthHurts/server/methods/user-met
hods.js:225:5)
I20160517-21:33:53.293(5.5)? at maybeAuditArgumentChecks (meteor://?app/live
data_server.js:1698:12)
I20160517-21:33:53.293(5.5)? at meteor://?app/livedata_server.js:708:19
I20160517-21:33:53.294(5.5)? at [object Object]._.extend.withValue (meteor:/
/?app/packages/meteor/dynamics_nodejs.js:56:1)
I20160517-21:33:53.294(5.5)? at meteor://?app/livedata_server.js:706:40
I20160517-21:33:53.294(5.5)? at [object Object]._.extend.withValue (meteor:/
/?app/packages/meteor/dynamics_nodejs.js:56:1)
I20160517-21:33:53.294(5.5)? at meteor://?app/livedata_server.js:704:46
I20160517-21:33:53.294(5.5)? at tryCallTwo (C:\Users\sameera\AppData\Local\.
meteor\packages\promise\0.5.1\npm\node_modules\meteor-promise\node_modules\promi
se\lib\core.js:45:5)
I20160517-21:33:53.294(5.5)? at doResolve (C:\Users\sameera\AppData\Local\.m
eteor\packages\promise\0.5.1\npm\node_modules\meteor-promise\node_modules\promis
e\lib\core.js:171:13)
I20160517-21:33:53.294(5.5)? at new Promise (C:\Users\sameera\AppData\Local\
.meteor\packages\promise\0.5.1\npm\node_modules\meteor-promise\node_modules\prom
ise\lib\core.js:65:3)
How do i implement this functionality. please help me
Upvotes: 0
Views: 2849
Reputation: 392
Accounts.forgotPassword
is a client-side only function. Instead of calling a meteor method, you can just call this function in your client code:
forgetPassword = () => {
let email = this.refs.email.value;
Accounts.forgotPassword({email: email}, function (e, r) {
if (e) {
console.log(e.reason);
} else {
// success
}
});
}
Upvotes: 2