Class: Admin::PersonSessionsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/admin/person_sessions_controller.rb

Overview

This controller handles the login/logout function of the site.

Instance Method Summary collapse

Instance Method Details

#createObject



9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/admin/person_sessions_controller.rb', line 9

def create
  @person_session = PersonSession.new(params[:person_session])
  if @person_session.save
    flash[:notice] = t('log.in.success').capitalize
  else
    flash[:error] = t('log.in.failed').capitalize
  end

  redirect_to_stored_location([forgeos_core, :admin, :root])
end

#destroyObject



20
21
22
23
# File 'app/controllers/admin/person_sessions_controller.rb', line 20

def destroy
  current_user_session.destroy
  flash[:notice] = t('log.out.success').capitalize
end

#newObject



5
6
7
# File 'app/controllers/admin/person_sessions_controller.rb', line 5

def new
  @person_session = PersonSession.new
end

#reset_passwordObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/controllers/admin/person_sessions_controller.rb', line 25

def reset_password
  user = Administrator.find_by_email(params[:email])
  if user
    generated_password = generate_password(8)
    if user.update_attributes(:password => generated_password, :password_confirmation => generated_password)
      UserNotifier.deliver_reset_password(user,generated_password)
      flash[:notice] = t('admin.reset_password.success').capitalize
    else
      flash[:error] = t('admin.reset_password.failed').capitalize
    end
  else
    flash[:error] = t('admin.not_exist').capitalize
  end
  redirect_to :action => 'new'
end