app/models/user.rb in devise_token_auth-0.1.19.alpha2 vs app/models/user.rb in devise_token_auth-0.1.19.alpha3
- old
+ new
@@ -11,10 +11,14 @@
validates_presence_of :confirm_success_url, if: Proc.new {|u| u.provider == 'email'}
# only validate unique emails among email registration users
validate :unique_email_user, on: :create
+ # can't set default on text fields in mysql, simulate here instead.
+ after_save :set_empty_token_hash
+ after_initialize :set_empty_token_hash
+
def valid_token?(token, client_id='default')
client_id ||= 'default'
return false unless self.tokens[client_id]
@@ -128,7 +132,11 @@
end
def email_required?
provider == 'email'
+ end
+
+ def set_empty_token_hash
+ self.tokens ||= {}
end
end