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!, #janus_scope, #mailer_class, #resource, #resource=, #resource_authentication_params, #resource_class, #resource_name
Instance Method Details
#after_destroy_url(resource) ⇒ Object
Where to redirect after user has unregistered.
60
61
62
|
# File 'lib/janus/controllers/registrations_controller.rb', line 60
def after_destroy_url(resource)
root_url
end
|
#after_sign_up_url(user) ⇒ Object
Where to redirect after user has registered.
55
56
57
|
# File 'lib/janus/controllers/registrations_controller.rb', line 55
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
|
# File 'lib/janus/controllers/registrations_controller.rb', line 50
def deliver_confirmation_instructions(resource)
mailer_class.confirmation_instructions(resource).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
64
65
66
67
68
69
|
# File 'lib/janus/controllers/registrations_controller.rb', line 64
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
|