Class: UsersController

Inherits:
ApplicationController show all
Defined in:
app/controllers/users_controller.rb

Instance Method Summary collapse

Instance Method Details

#confirmObject



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'app/controllers/users_controller.rb', line 39

def confirm
  @user = User.find_using_perishable_token params[:token]  
  if @user
    @user.confirmed_at = Time.now
    @user.save
    UserSession.create @user
    flash[Rails.application.config.constellation.authentication.success_flash] = t("constellation.authentication.users.confirm.success_flash")
    redirect_to Rails.application.config.constellation.authentication.confirm_redirection
  else
    flash.now[Rails.application.config.constellation.authentication.failure_flash] = t("constellation.authentication.users.confirm.failure_flash")
    redirect_to resend_confirmation_path
  end
end

#createObject



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

def create
  @user = User.new(params[:user])
  if @user.save
    UserMailer.confirmation(@user).deliver if Rails.application.config.constellation.authentication.
    flash[Rails.application.config.constellation.authentication.success_flash] = t("constellation.authentication.users.create.success_flash")
    redirect_to Rails.application.config.constellation.authentication.
  else
    render :action => :new
  end
end

#editObject



24
25
26
# File 'app/controllers/users_controller.rb', line 24

def edit
  @user = @current_user
end

#newObject



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

def new
  @user = User.new
end

#resend_confirmationObject



53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'app/controllers/users_controller.rb', line 53

def resend_confirmation
  if request.post?
    @user = User.find_by_email params[:email]
    if @user
      @user.reset_perishable_token!
      UserMailer.confirmation(@user).deliver
      flash.now[Rails.application.config.constellation.authentication.success_flash] = t("constellation.authentication.users.resend_confirmation.success_flash")
      redirect_to Rails.application.config.constellation.authentication.resend_confirmation_redirection
    else
      flash.now[Rails.application.config.constellation.authentication.failure_flash] = t("constellation.authentication.users.resend_confirmation.failure_flash")
    end
  end
end

#showObject



20
21
22
# File 'app/controllers/users_controller.rb', line 20

def show
  @user = @current_user
end

#updateObject



28
29
30
31
32
33
34
35
36
# File 'app/controllers/users_controller.rb', line 28

def update
  @user = @current_user
  if @user.update_attributes(params[:user])
    flash[Rails.application.config.constellation.authentication.success_flash] = t("constellation.authentication.users.update.success_flash")
    redirect_to 
  else
    render :action => :edit
  end
end