Class: PasswordResetsController

Inherits:
ReaderActionController show all
Defined in:
app/controllers/password_resets_controller.rb

Instance Method Summary collapse

Methods inherited from ReaderActionController

#default_welcome_url, #logged_in?, #logged_in_admin?, #logged_in_user?, #permission_denied

Instance Method Details

#createObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/password_resets_controller.rb', line 15

def create
  @forgetter = Reader.find_by_email(params[:email])
  if @forgetter
    if @forgetter.activated?
      @forgetter.send_password_reset_message
      render
    else
      @forgetter.send_activation_message
      redirect_to new_reader_activation_url
    end
  else  
    @error = flash[:error] = t("reader_extension.email_unknown")
    render :action => :new  
  end  
end

#editObject



31
32
33
34
35
36
# File 'app/controllers/password_resets_controller.rb', line 31

def edit  
  unless @reader
    flash[:error] = t('reader_extension.reset_not_found')
  end
  render
end

#newObject



11
12
13
# File 'app/controllers/password_resets_controller.rb', line 11

def new
  render
end

#updateObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'app/controllers/password_resets_controller.rb', line 38

def update
  if @reader 
    @reader.password = params[:reader][:password]
    @reader.password_confirmation = params[:reader][:password_confirmation]
    if @reader.save 
      self.current_reader = @reader
      flash[:notice] = t('reader_extension.password_updated_notice')
      redirect_to default_welcome_url(@reader)
    else
      flash[:error] = t('reader_extension.password_mismatch')
      render :action => :edit 
    end  
  else
    flash[:error] = t('reader_extension.reset_not_found')
    render :action => :edit     # without @reader, this will take us back to the enter-your-code form
  end
end