2016-08-22 11 views

回答

1
  1. 只是寫在devise.rb

    config.allow_unconfirmed_access_for = nil 
    
  2. 寫一個驗證的application.rb中

    def is_confirmed? 
    if user_signed_in? 
        if current_user.confirmed? 
         return true 
        else 
         flash[:notice] = "You are not allow to view this page." 
         redirect_to dashboard_path # your dashboard path 
        end 
    end 
    end 
    
  3. 使用您的位指示

    before_action :is_confirmed?, except: [:dashbord] 
    
0

我想你可以用色器件實現這一點,allowing-unconfirmed-access

只需添加extreamely長時間,讓他們登錄,然後就檢查用戶是否已確認電子郵件 - 告訴他們所有的儀表盤的內容,反之亦然。

或者你可以跳過:confirmable驗證。

希望這會有所幫助。

0

退房此Wiki網頁https://github.com/plataformatec/devise/wiki/How-To:-Add-:confirmable-to-Users

#解決方案1 ​​devise.rb像您可以配置:

config.allow_unconfirmed_access_for = nil 

因此,這意味着用戶可以訪問沒有任何確認,但例如:

config.allow_unconfirmed_access_for = 1.hour 

因此,他們可以在1小時內訪問UT確認

#方案2

# in User.rb 
protected 
def confirmation_required? 
    false 
end 

所以現在使用可以在不確認任何訪問,但我認爲解決的辦法#1更高效!