簡體   English   中英

在驗證電子郵件之前,Meteor.js重定向到“專用”頁面

[英]Meteor.js redirect to “dedicated” page before email is verified

我有嘗試執行的邏輯,但我沒有這樣做...這就是問題。 我已經為新用戶實施了確認郵件,現在我將使用下面將粘貼的代碼粘貼代碼,基本上是在用戶確認其電子郵件地址之前阻止該用戶登錄該應用程序。 好吧,很清楚。 但是,現在我想將他發送到專用的“驗證”頁面,該頁面上只會顯示諸如“您需要先驗證電子郵件才能登錄,單擊以重新發送確認鏈接,blablabla”之類的文本。 林還使用鐵路由器。

我這樣做是為了檢查:

//(server-side) called whenever a login is attempted
Accounts.validateLoginAttempt(function(attempt){
  if (attempt.user && attempt.user.emails && !attempt.user.emails[0].verified ) {
    console.log('email not verified');

    // Router.go('verification'); - some kind of my "logic" what I want to 


  }
  return true;
});

這里和評論中都討論了相同的問題 ,用戶建議重新發送驗證電子郵件令牌並警告用戶,而不是重定向到頁面,這會更簡單。 該代碼如下所示:

Accounts.validateLoginAttempt(function(attempt){
  if (attempt.user && attempt.user.emails && !attempt.user.emails[0].verified ) {
    Accounts.sendVerificationEmail(user._id);
    Alert('Your email has not been verified, we have re-sent the email. Please verify before logging in.');
    //you could also use a modal or something fancy if you want.

}
  return true;
});

如果肯定要創建一個頁面,可以在此處找到有關執行此操作的方法的答案 ,但是如何執行此操作取決於是否要使其成為布局的一部分。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM