meteor-accounts-ui-bootstrap-3 icon indicating copy to clipboard operation
meteor-accounts-ui-bootstrap-3 copied to clipboard

Resend Verification Email button in logged-in dropdown menu

Open edemaine opened this issue 9 years ago • 0 comments

I wanted this functionality: If the user is logged in but they have an unverified email address, present a "Resend Verification Email" button in the login dropdown menu which triggers a method that calls Accounts.sendVerificationEmail.

This was easy enough for me to add, thanks to the _loginButtonsAdditionalLoggedInDropdownActions feature, but I wonder if it would be a useful feature for everyone (perhaps turned on by an Accounts.ui.config setting). In any case, here is my code:

## client/accounts.jade
template(name='_loginButtonsAdditionalLoggedInDropdownActions')
  if unverified
    button.btn.btn-default.btn-block#login-buttons-resend-verification Resend Verification Email

## client/accounts.coffee
Template._loginButtonsAdditionalLoggedInDropdownActions.helpers
  unverified: ->
    _.some Meteor.user().emails, (user) -> not user.verified

Template._loginButtonsAdditionalLoggedInDropdownActions.events
  'click #login-buttons-resend-verification': (e) ->
    Meteor.call 'resendVerificationEmail'

## lib/accounts.coffee
Meteor.methods
  resendVerificationEmail: ->
    check Meteor.userId(), String
    unless @isSimulation
      Accounts.sendVerificationEmail Meteor.userId()

edemaine avatar Dec 20 '15 18:12 edemaine