Created
March 25, 2015 20:42
-
-
Save ralfting/b017c43b955e0d2d83ae to your computer and use it in GitHub Desktop.
User.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User < ActiveRecord::Base | |
belongs_to :company | |
# Include default devise modules. Others available are: | |
# :token_authenticatable, :confirmable, | |
# :lockable, :timeoutable and :omniauthable | |
devise :database_authenticatable, | |
:recoverable, :rememberable, :trackable, :validatable, :confirmable | |
# Create a password reset token for this user, saves it encrypted and returns the raw token text | |
def setup_password_reset | |
raw, enc = Devise.token_generator.generate(self.class, :reset_password_token) | |
self.reset_password_token = enc | |
self.reset_password_sent_at = Time.now.utc | |
self.save(validate: false) | |
return raw | |
end | |
def send_password_reset | |
token = setup_password_reset | |
DinamMailer.password_reset(self, token).deliver | |
end | |
handle_asynchronously :send_password_reset | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment