Meteor帐户电子邮件验证失败有两种方式

时间:2013-10-01 09:21:33

标签: meteor iron-router

我的电子邮箱上挂了电子邮件,并在创建用户后收到验证邮件。我可以点击附带的链接,它会将我带到我的主页面。

1)点击链接似乎会进行一些处理,因为它会重定向到/,但它不会更改用户帐户上的已验证标记。

2)它似乎忽略了我的Accounts.config设置,只有在我明确调用

时才有效
token = Accounts.sendVerificationEmail(userId)

详细信息:

mrt --version
Meteorite version 0.6.11
Release 0.6.5.1

mrt list --using

standard-app-packages
preserve-inputs
less
coffeescript
iron-router
foundation
http
moment
email
spin
roles
accounts-base
accounts-password
accounts-ui

服务器/ LIB / account.coffee

Accounts.config
  sendVerificationEmail: true          
  forbidClientAccountCreation: true

服务器方法:

Meteor.startup ->
  create_user = (options) ->
    console.log('create_user: ' + options.username)
    userId = Accounts.createUser options

    # should not be necessary, but I get email only when included
    token = Accounts.sendVerificationEmail(userId)


  Meteor.methods({ create_user: create_user })  

在上面调用之后,mongo显示:

emails: [ { "address" : "jim@less2do.com" , "verified" : false}]

and

email: { "verificationTokens" : [ { "token" : "N3sLEDMsutTbjxyzX" , "address" : "jim@less2do.com" , "when" : 1.380616343673E12}]}

获取默认电子邮件:

Hello,    
To verify your account email, simply click the link below.    
http://localhost:3000/#/verify-email/N3sLEDMsutTbjxyzX        
Thanks.    

点击上面的链接可以转到:

http://localhost:3000/

但mongo db没有变化。

我期待通过帐户密码处理/#/ verify-email / N3sLEDMsutTbjxyzX吸引一些内容并更新用户文档。

accounts-base.js尝试使用

match = window.location.hash.match(/^\#\/verify-email\/(.*)$/);

但此时位置哈希值为空。

我是否遗漏了需要手动设置路线的内容?我用铁路由器毁了东西吗?以防万一,

Router.map ->
  this.route 'home',
    path: '/'

  this.route 'inboxes'
  this.route 'availability'
  this.route 'find-agent'
  this.route 'inbox-tour'
  this.route 'availability-tour'
  this.route 'find-agent-tour'

  this.route 'inbox', 
    path: '/inbox/:_id'
    data: () ->

      m = Messages.findOne this.params._id
      m._markRead()
      fixed = _.map m.history.versions, (msg) =>
        msg.left = (msg.author is 'offer')
        msg.body = msg.body.replace( /[\r\n]+/g, "<br>")
        msg
      m.history.versions = fixed
      Session.set  'messageVersions', fixed
      m

    waitOn: db.subscriptions.messages
    loadingTemplate: 'loading'
    notFoundTemplate: 'notFound'

  this.route 'register',
  this.route 'requested',
  this.route 'blog',
  this.route 'test',
  this.route 'aboutUs'        

Router.configure
  layout: 'layout'

  notFoundTemplate: 'notFound'

  loadingTemplate: 'loading'

  renderTemplates: 
    'footer': { to: 'footer' }
    'sidebar': { to: 'sidebar' }



  ### Commented to rule out this routine
  before: ->
    routeName = @context.route.name
    debugger

    # no need to check at these URLs
    #, etc 
    return  if _.include(["request", "passwordReset","register", "tour"], routeName)
    return  if _.intersection(routeName.split('-'), ["tour"]).length > 0
    return if routeName.indexOf('verify-email') != -'' 
    user = Meteor.user()
    unless user
      #@render (if Meteor.loggingIn() then @loadingTemplate else "/")
      if Meteor.loggingIn()
        console.log('still logging in, no user, to ' + @loadingTemplate)
        @render @loadingTemplate
        console.log('!render ' + @loadingTemplate + ' completed' )
      else
        console.log('no user, / from router over ' + @loadingTemplate)
        @render "home"
      @stop()
  ###

谢谢!

2 个答案:

答案 0 :(得分:5)

显然,铁路由器和路由器中存在hashbangs的路由器存在一个已知问题,就像它通过电子邮件生成的那样:

https://github.com/EventedMind/iron-router/issues/3

我建议您尝试实现与用户samhatoum所说的相同的解决方案(小心我认为,因为他将代码放在RootController中的extends方法上已更改为extend

答案 1 :(得分:3)

我确认,现在这完全正常。一旦我重定向到应用程序的根目录,我就会这样做。

阅读更多Verify an Email with Meteor Accounts

// (client-side)
Template.Homepage.created = function() {
  if (Accounts._verifyEmailToken) {
    Accounts.verifyEmail(Accounts._verifyEmailToken, function(err) {
      if (err != null) {
        if (err.message = 'Verify email link expired [403]') {
          console.log('Sorry this verification link has expired.')
        }
      } else {
        console.log('Thank you! Your email address has been confirmed.')
      }
    });
  }
};