Class: Janus::RegistrationsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Janus::RegistrationsController
show all
- Includes:
- InternalHelpers
- Defined in:
- lib/janus/controllers/registrations_controller.rb
Instance Method Summary
collapse
#authenticate!, #initialize_resource, #janus_scope, #mailer_class, #resource, #resource=, #resource_authentication_params, #resource_class, #resource_name, #respond_with_failure, #respond_with_success
Instance Method Details
#after_destroy_url(resource) ⇒ Object
Where to redirect after user has unregistered.
61
62
63
|
# File 'lib/janus/controllers/registrations_controller.rb', line 61
def after_destroy_url(resource)
root_url
end
|
#after_sign_up_url(user) ⇒ Object
Where to redirect after user has registered.
56
57
58
|
# File 'lib/janus/controllers/registrations_controller.rb', line 56
def after_sign_up_url(user)
user
end
|
#create ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/janus/controllers/registrations_controller.rb', line 19
def create
self.resource = resource_class.new(send("#{janus_scope}_params"))
if resource.save
janus.login(resource, :scope => janus_scope, :rememberable => true)
deliver_confirmation_instructions(resource) if resource.respond_to?(:confirm!)
else
resource.clean_up_passwords
end
respond_with(resource, :location => after_sign_up_url(resource))
end
|
#deliver_confirmation_instructions(resource) ⇒ Object
Simple wrapper for Mailer#confirmation_instructions.deliver to allow customization of the email (eg: to pass additional data).
50
51
52
53
|
# File 'lib/janus/controllers/registrations_controller.rb', line 50
def deliver_confirmation_instructions(resource)
mail = mailer_class.confirmation_instructions(resource)
mail.respond_to?(:deliver_later) ? mail.deliver_later : mail.deliver
end
|
#destroy ⇒ Object
39
40
41
42
43
44
45
46
|
# File 'lib/janus/controllers/registrations_controller.rb', line 39
def destroy
self.resource = send("current_#{janus_scope}")
janus.unset_user(janus_scope) if resource.destroy
respond_with(resource) do |format|
format.html { redirect_to after_destroy_url(resource) }
end
end
|
#edit ⇒ Object
14
15
16
17
|
# File 'lib/janus/controllers/registrations_controller.rb', line 14
def edit
self.resource = send("current_#{janus_scope}")
respond_with(resource)
end
|
#new ⇒ Object
9
10
11
12
|
# File 'lib/janus/controllers/registrations_controller.rb', line 9
def new
self.resource = resource_class.new
respond_with(resource)
end
|
#resource_params ⇒ Object
65
66
67
68
69
70
|
# File 'lib/janus/controllers/registrations_controller.rb', line 65
def resource_params
keys = %w{current_password password password_confirmation}
send("#{janus_scope}_params").reject do |key, value|
value.blank? and keys.include?(key)
end
end
|
#update ⇒ Object
32
33
34
35
36
37
|
# File 'lib/janus/controllers/registrations_controller.rb', line 32
def update
self.resource = send("current_#{janus_scope}")
resource.current_password = ""
resource.clean_up_passwords unless resource.update_attributes(resource_params)
respond_with(resource, :location => after_sign_up_url(resource))
end
|