2017-10-24 2 views
0

Ich kann nicht finden, wo Devise einen Benutzer als bestätigt markiert oder nicht?Wo speichert das Benutzerbestätigungsflag?

Manchmal möchte ich nur einen Benutzer erstellen und den Benutzer automatisch bestätigen. Ich weiß, dass es eine Übersprungbestätigungsfunktion gibt, aber neugierig, wo diese in der Datenbank gespeichert wird.

+0

Spalte 'confirmed_at' in' users' Tabelle. –

Antwort

0

Devise :: Confirmable verwendet die Spalte datatime Spalte confirmed_at.

# Confirmable tracks the following columns: 
# 
# * confirmation_token - A unique random token 
# * confirmed_at   - A timestamp when the user clicked the confirmation link 
# * confirmation_sent_at - A timestamp when the confirmation_token was generated (not sent) 
# * unconfirmed_email - An email address copied from the email attr. After confirmation 
#       this value is copied to the email attr then cleared 

Da die Spalte auf NULL festlegbare die Implementierungen ist so einfach wie:

module Devise 
    module Models 
    module Confirmable 
     # ... 
     def confirmed? 
     !!confirmed_at 
     end 
    end 
    end 
end 

Welche weil in Ruby alles funktioniert außer null und falsch wahr sind. Das Setzen von confirmed_at auf ein beliebiges Datetime (auch in der Zukunft) wird den Datensatz bestätigen.

module Devise 
    module Models 
    module Confirmable 
     # If you don't want confirmation to be sent on create, neither a code 
     # to be generated, call skip_confirmation! 
     def skip_confirmation! 
     self.confirmed_at = Time.now.utc 
     end 
    end 
    end 
end 

Von the Devise source.