Module: EasyAuth::Controllers::PasswordReset

Included in:
PasswordResetController
Defined in:
lib/easy_auth/controllers/password_reset.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



2
3
4
5
6
# File 'lib/easy_auth/controllers/password_reset.rb', line 2

def self.included(base)
  base.instance_eval do
    before_filter :find_account_from_reset_token, :only => [:edit, :update]
  end
end

Instance Method Details

#after_failed_attempted_password_resetObject



53
54
55
# File 'lib/easy_auth/controllers/password_reset.rb', line 53

def after_failed_attempted_password_reset
  after_successful_attempted_password_reset
end

#after_failed_password_resetObject



43
44
45
46
# File 'lib/easy_auth/controllers/password_reset.rb', line 43

def after_failed_password_reset
  flash.now[:error] = I18n.t('easy_auth.password_reset.update.error')
  render :edit
end

#after_successful_attempted_password_resetObject



48
49
50
51
# File 'lib/easy_auth/controllers/password_reset.rb', line 48

def after_successful_attempted_password_reset
  flash.now[:notice] = I18n.t('easy_auth.password_reset.create.notice')
  render :new
end

#after_successful_password_resetObject



33
34
35
36
37
# File 'lib/easy_auth/controllers/password_reset.rb', line 33

def after_successful_password_reset
  session[:identity_id] = @identity.id
  @identity.update_column(:reset_token_digest, nil)
  redirect_to after_successful_password_reset_url, :notice => I18n.t('easy_auth.password_reset.update.notice')
end

#after_successful_password_reset_urlObject



39
40
41
# File 'lib/easy_auth/controllers/password_reset.rb', line 39

def after_successful_password_reset_url
  @identity.
end

#createObject



12
13
14
15
16
17
18
19
20
21
# File 'lib/easy_auth/controllers/password_reset.rb', line 12

def create
  if @identity = EasyAuth.find_identity_model(params).where(:uid => params[:identities_password][:uid]).first
    unencrypted_reset_token = @identity.generate_reset_token!
    PasswordResetMailer.reset(@identity.id, unencrypted_reset_token).deliver
    after_successful_attempted_password_reset
  else
    @identity = EasyAuth.find_identity_model(params).new(uid: params[:identities_password][:uid])
    after_failed_attempted_password_reset
  end
end

#newObject



8
9
10
# File 'lib/easy_auth/controllers/password_reset.rb', line 8

def new
  @identity = EasyAuth.find_identity_model(params).new
end

#updateObject



23
24
25
26
27
28
29
30
31
# File 'lib/easy_auth/controllers/password_reset.rb', line 23

def update
  @identity = @account.password_identities.first

  if @account.update_attributes()
    after_successful_password_reset
  else
    after_failed_password_reset
  end
end