トークンがまだ有効かどうかを確認することはかなり簡単です。
あなたはの行に何かを行うことができます:
accounts-password
パッケージのコードから適応
Meteor.methods({
checkResetToken(token) {
check(token, String);
const user = Meteor.users.findOne({
"services.password.reset.token": token});
if (!user) { // never existed or already been used
throw new Meteor.Error(403, "Token expired");
}
const when = user.services.password.reset.when;
const reason = user.services.password.reset.reason;
let tokenLifetimeMs = Accounts._getPasswordResetTokenLifetimeMs();
if (reason === "enroll") {
tokenLifetimeMs = Accounts._getPasswordEnrollTokenLifetimeMs();
}
const currentTimeMs = Date.now();
if ((currentTimeMs - when) > tokenLifetimeMs) { // timeout
throw new Meteor.Error(403, "Token expired");
}
// you can return some of the user's details to further improve the UX.
}
});
。
トークンがまだ有効かどうかを判断して、サーバーからユーザーの詳細を取得する(たとえば、登録トークンであるか、ユーザーの名前/電子メールであるかなど)ためにクライアントサイドフックで使用します)を使用して、よりパーソナライズされたビューを表示します。
user
にはすべての秘密フィールドが含まれているため、すべての秘密フィールドをクライアントに返すわけではありません。
恐ろしい答え、どうもありがとう! –