2017-06-23 29 views
0

我知道這已被問了很多,我見過很多解決方案,似乎並不適用於我的問題,所以我很抱歉如果我錯過了一些東西。ng-token-auth並設計令牌驗證確認重定向url

當使用ng-token-auth和devise-token-auth發送確認郵件時,確認郵件鏈接沒有redirect_url,點擊它時會顯示錯誤頁面,但確認API調用成功。在ng-token-auth配置

我設置: confirmationSuccessUrl: 'http://localhost:8000/#!/login'

devise_token_auth.rb我還設置: config.default_confirm_success_url = 'http://localhost:8000/#!/login'

我也試着重寫ConfirmationsController其他許多解決方案建議,都無濟於事。

我已通過添加redirect_urlconfrimation_url調用了臨時變通通過編輯色器件視圖confirmation_instructions.html.erb:提前

confirmation_url(@resource, redirect_url:'http://localhost:8000/#!/login', confirmation_token: @token)

感謝,並請讓我知道如果我可以提供任何額外的信息。

回答

0

看起來鏈接總是發送一個HTTP 406,所以對象總是有錯誤,但並不總是消息。從目前來看,我實現了(醜陋的)解決方案通過重寫確認控制器例如:

def show 
    self.resource = resource_class.confirm_by_token(params[:confirmation_token]) 
    yield resource if block_given? 

    if resource.errors.messages.empty? 
     set_flash_message!(:notice, :confirmed) 
     #respond_with_navigational(resource){ redirect_to after_confirmation_path_for(resource_name, resource) } 
     if signed_in?(resource_name) 
      #signed_in_root_path(root_path) 
      redirect_to root_path + '#!/users/' + resource.id.to_s 
     else 
      redirect_to root_path + '#!/login' 
     end 
    else 
     respond_with_navigational(resource.errors, status: :unprocessable_entity){ render :new } 
    end 
end 

這意志,在最壞的情況,重定向到登錄頁面。由於確認API調用實際上正在工作,用戶可以登錄。如果失敗,我可以顯示一條Flash消息,指示他們應該嘗試重新發送確認電子郵件。

如果有人知道更好的解決方案或我做錯了什麼導致HTTP 406請讓我知道!