Class: Gluttonberg::Public::MembersController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/gluttonberg/public/members_controller.rb

Instance Attribute Summary

Attributes inherited from BaseController

#locale, #page

Instance Method Summary collapse

Instance Method Details

#confirmObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/controllers/gluttonberg/public/members_controller.rb', line 36

def confirm
  @member = Member.where(:confirmation_key => params[:key]).first
  if @member
    @member.profile_confirmed = true
    @member.save
    flash[:notice] = "Your registration is now complete."
    redirect_to root_url
  else
    flash[:notice] = "We're sorry, but we could not locate your account. " +
    "If you are having issues try copying and pasting the URL " +
    "from your email into your browser."
    redirect_to root_url
  end
end

#createObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/gluttonberg/public/members_controller.rb', line 14

def create
  @member = Member.new(params[:gluttonberg_member])
  if Member.does_email_verification_required
    @member.confirmation_key = Digest::SHA1.hexdigest(Time.now.to_s + rand(12341234).to_s)[1..24]
  else  
    @member.profile_confirmed = true
  end
  if @member && @member.save
    if Member.does_email_verification_required
      MemberNotifier.confirmation_instructions(@member.id,current_localization_slug).deliver
      flash[:notice] = "Please check your email for a confirmation."
    else
      flash[:notice] = "Your registration is now complete."
    end
    redirect_to root_path
  else
    @page_title = "Register"
    render :new
  end
end

#editObject



78
79
80
# File 'app/controllers/gluttonberg/public/members_controller.rb', line 78

def edit
  @member = current_member
end

#newObject



9
10
11
12
# File 'app/controllers/gluttonberg/public/members_controller.rb', line 9

def new
  @page_title = "Register"
  @member = Member.new
end

#resend_confirmationObject



51
52
53
54
55
56
57
58
59
60
# File 'app/controllers/gluttonberg/public/members_controller.rb', line 51

def resend_confirmation
  if current_member.confirmation_key.blank?
    confirmation_key = Digest::SHA1.hexdigest(Time.now.to_s + rand(12341234).to_s)[1..24]
    current_member.confirmation_key = confirmation_key
    current_member.save
  end
  MemberNotifier.confirmation_instructions(current_member.id,current_localization_slug).deliver if current_member && !current_member.profile_confirmed
  flash[:notice] = "Please check your email for a confirmation."
  redirect_to member_profile_url
end

#showObject



74
75
76
# File 'app/controllers/gluttonberg/public/members_controller.rb', line 74

def show
  @member = current_member
end

#updateObject



62
63
64
65
66
67
68
69
70
71
72
# File 'app/controllers/gluttonberg/public/members_controller.rb', line 62

def update
  @member = current_member
  if @member.update_attributes(params[:gluttonberg_member])
    @member.save
    if params[:gluttonberg_member][:return_url]
      redirect_to params[:gluttonberg_member][:return_url]
    else
      redirect_to root_path
    end
  end
end