Skip to content
This repository has been archived by the owner on May 18, 2021. It is now read-only.

Commit

Permalink
Fix remind password
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeyfrank committed Feb 15, 2013
1 parent 1610614 commit 4f861b7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
3 changes: 2 additions & 1 deletion app/controllers/web/remind_passwords_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ def create
if @type.valid?
user = @type.user
if user && user.active?
user.remind_password
token = user.create_auth_token
UserMailer.remind_password(user, token).deliver
flash_success
return redirect_to root_path
end
Expand Down
10 changes: 2 additions & 8 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ class User < ActiveRecord::Base
end


def build_auth_token
def create_auth_token
token = SecureHelper.generate_token
expired_at = Time.current + configus.token.lifetime
auth_tokens.build :authentication_token => token, :expired_at => expired_at
auth_tokens.create! :authentication_token => token, :expired_at => expired_at
end

def full_name
Expand All @@ -56,10 +56,4 @@ def password
@real_password
end

def remind_password
token = self.build_auth_token
token.save!
UserMailer.remind_password(self, token).deliver
end

end
3 changes: 1 addition & 2 deletions test/functional/web/account/passwords_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
class Web::Account::PasswordsControllerTest < ActionController::TestCase
setup do
@user = create :user
@token = @user.build_auth_token
@token.save!
@token = @user.create_auth_token
end

test "should get edit" do
Expand Down

0 comments on commit 4f861b7

Please sign in to comment.