Class: CreateAccountsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
lib/dangerzone/templates/controllers/create_accounts_controller.rb

Instance Method Summary collapse

Instance Method Details

#confirmObject



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/dangerzone/templates/controllers/create_accounts_controller.rb', line 24

def confirm
  @user = User.find_by_id(params[:id])
  if @user.try(:in_time?) && @user.token_matches?(params[:reset_password_token])
    reset_session
    @user.confirm!(request.remote_ip)
    session[:user_id] = @user.id
    redirect_to :root, notice: "User confirmation successful."
  else
    redirect_to :sign_up, notice: "User confirmation unsuccessful."
  end
end

#createObject



3
4
5
6
7
8
9
10
11
12
# File 'lib/dangerzone/templates/controllers/create_accounts_controller.rb', line 3

def create
  @user = User.new(params[:user])
  @user.confirmed = false
  if @user.update_reset_password_credentials
    DangerzoneMailer.(@user).deliver
    redirect_to :check_your_email, notice: "Registration successful."
  else
    redirect_to :sign_up, notice: "Registration unsuccessful"
  end
end

#newObject



36
37
# File 'lib/dangerzone/templates/controllers/create_accounts_controller.rb', line 36

def new
end

#resend_confirmation_emailObject



14
15
16
17
18
19
20
21
22
# File 'lib/dangerzone/templates/controllers/create_accounts_controller.rb', line 14

def resend_confirmation_email
  @user = User.find_by_email(params[:email].try(:downcase))
  if @user.try(:update_reset_password_credentials) && !@user.confirmed
    DangerzoneMailer.(@user).deliver
    redirect_to :check_your_email, notice: 'Resent confirmation email.'
  else
    redirect_to :check_your_email, notice: 'Unable to resend confirmation email.'
  end
end