ng-token-auth icon indicating copy to clipboard operation
ng-token-auth copied to clipboard

Resend Confirmation Email

Open samstickland opened this issue 9 years ago • 14 comments

Hi,

Is it possible to resend a confirmation email? I don't see the hooks in the API.

Thanks,

Sam

samstickland avatar Dec 20 '14 18:12 samstickland

I've dug into this a little further. The devise ConfirmationsController exposes two public methods, create and show, but devise_token_auth only defines show, not create. So it seems like devise_token_auth doesn't have the capability to resend confirmation emails, which would need to be the first step.

samstickland avatar Dec 21 '14 20:12 samstickland

@samstickland - I don't believe reconfirmation has been implemented. I'll be doing extensive work on this gem over the next few days, and I'll see what I can do about this issue.

lynndylanhurley avatar Dec 21 '14 22:12 lynndylanhurley

Excellent, thanks! Let me know if you want me to do any testing.

samstickland avatar Dec 22 '14 07:12 samstickland

Any updates on this?

sdornan avatar Jan 28 '15 18:01 sdornan

Would love to hear if there's any updates on this as well.

mkhatib avatar Feb 07 '15 21:02 mkhatib

I managed to add this by overriding confirmations controller as below and making calls to POST /auth/confirmation

If this looks good, I am happy to make a pull request.

    mount_devise_token_auth_for 'User', at: '/auth', controllers: {
      confirmations:  'api/v1/confirmations'
    }
class Api::V1::ConfirmationsController < DeviseTokenAuth::ConfirmationsController

  def create
    unless resource_params[:email]
      return render json: {
        success: false,
        errors: ['You must provide an email address.']
      }, status: 400
    end

    unless params[:redirect_url]
      return render json: {
        success: false,
        errors: ['Missing redirect url.']
      }, status: 400
    end

    if resource_class.case_insensitive_keys.include?(:email)
      email = resource_params[:email].downcase
    else
      email = resource_params[:email]
    end

    q = "uid = ? AND provider='email'"

    # fix for mysql default case insensitivity
    if ActiveRecord::Base.connection.adapter_name.downcase.starts_with? 'mysql'
      q = "BINARY uid = ? AND provider='email'"
    end

    @resource = resource_class.where(q, email).first

    errors = nil

    if @resource
      @resource.send_confirmation_instructions({
        redirect_url: params[:confirm_success_url],
        client_config: params[:config_name]
      })
    else
      errors = ["Unable to find user with email '#{email}'."]
    end

    if errors
      render json: {
        success: false,
        errors: errors
      }, status: 400
    else
      render json: {
        status: 'success',
        data:   @resource.as_json
      }
    end

  end
end

mkhatib avatar Feb 07 '15 22:02 mkhatib

Any updates on this? Can't see anything on this in the docs.

stephenbaidu avatar Sep 10 '15 00:09 stephenbaidu

+1

jasonaibrahim avatar Nov 30 '15 21:11 jasonaibrahim

+1

dchersey avatar Mar 29 '16 20:03 dchersey

+1

ronshoshani avatar May 07 '16 10:05 ronshoshani

@lynndylanhurley can we start adding "need help" labels to tickets like these. You don't have to do all the work. I'll even learn coffee-script if i have too 😝

angelxmoreno avatar May 09 '16 14:05 angelxmoreno

looks like we already had a helps wanted label already =]

booleanbetrayal avatar May 10 '16 02:05 booleanbetrayal

This is not ng-token-auth issue, but devise_token_auth. Can you please submit a PR to this repo? Thanks in advance.

v3rron avatar Jun 18 '16 18:06 v3rron

hi! Any update on this?

alemata avatar Oct 18 '16 18:10 alemata