okland / accounts-phone

A login service based on mobile phone number for Meteor
117 stars 87 forks source link

Make user-login optional in verifyPhone method #21

Open ChenLi0830 opened 8 years ago

ChenLi0830 commented 8 years ago

Hi there, I am using the package and I find it very helpful so far, thank you very much for it.

I'm wondering if you could make user-login an optional action in verifyPhone method? I want to show users a welcome page after they successfully register, but currently I can't do it because the verifyPhone function will bring them directly into the main page.

Thanks! Yichen

ahmedtabrez commented 8 years ago

@ChenLi0830, Perform phone verification on server side. The user won't be logged in.

ChenLi0830 commented 8 years ago

@ahmedtabrez, thanks for your reply. It works like a charm. However, when reading the code I got confused what prevented the 'login' process from happening. To me it seems all Account.verifyPhone method does is checking the params, and then directly call the server method 'verifyPhone'. Clearly, there is something I missed, but I don't know what it is.

Here is the code I looked at in phone_client.js in the package

Accounts.verifyPhone = function (phone, code, newPassword, callback) {
    check(code, String);
    check(phone, String);

    var hashedPassword;

    if (newPassword) {
        // If didn't gave newPassword and only callback was given
        if (typeof(newPassword) === 'function') {
            callback = newPassword;
        } else {
            check(newPassword, String);
            hashedPassword = Accounts._hashPassword(newPassword);
        }
    }
    Accounts.callLoginMethod({
        methodName     : 'verifyPhone',
        methodArguments: [phone, code, hashedPassword],
        userCallback   : callback});
};