Meteor js - "please re-enter your password to do that" - how to reauth while already logged in?

StackOverflow https://stackoverflow.com/questions/18222086

سؤال

In Meteor, how do i check if some input password string matches the currently logged-in user's actual password? I'm looking to have certain more sensitive settings only be able to be changed if you re-enter your password, similar to how github does sensitive stuff.

In the application I'm working on, a shift manager will sign into the meteor app at the beginning of the day, and this unlocks the UI for employees / cashiers to use until the manager signs out. However, while the manager is doing something else, if an employee tries to, say, edit the cash drawer totals, they'll be prompted for the manager's password. If they enter an incorrect password, it just shouldn't let them do that operation, but it shouldn't log them out.

هل كانت مفيدة؟

المحلول

Where userPassword is the user submitted password. Note there is no underscore before id.

Meteor.loginWithPassword({id: localStorage['Meteor.userId'] }, userPassword, function (error) {
    if(!error) {
        // good to go.
    } else {
        // not this time, pal.
    }
});
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top