Class: Cheapskate::ApplicationController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- Cheapskate::ApplicationController
show all
- Includes:
- ApplicationHelper
- Defined in:
- app/controllers/cheapskate/application_controller.rb
Instance Method Summary
collapse
#url_options_for_protocol
Instance Method Details
#complete_login ⇒ Object
34
35
36
37
38
39
40
41
42
43
|
# File 'app/controllers/cheapskate/application_controller.rb', line 34
def complete_login
login = SingleUseLogin.find_by_token(params[:token])
if login.nil?
alert_and_redirect('Unable to verify login. Try again?', login_path, :error)
end
user = login.get_user_and_destroy!
@client.store_user_in_session(user, session)
alert_and_redirect("Welcome, #{@client.user_name(user)}!", Cheapskate::CONFIG['ROOT_PATH'])
end
|
#complete_registration ⇒ Object
16
17
18
|
# File 'app/controllers/cheapskate/application_controller.rb', line 16
def complete_registration
alert_and_redirect("Thank you for registering.", Cheapskate::CONFIG['ROOT_PATH'])
end
|
#login ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'app/controllers/cheapskate/application_controller.rb', line 20
def login
user = @client.find_user(params)
if user.nil?
return alert_and_redirect('That user does not exist.', login_path, :error)
end
if !@client.authenticate_user(user, params)
return alert_and_redirect('You have entered an incorrect password.', login_path, :error)
end
login = SingleUseLogin.create!(:user => user)
redirect_to(logged_in_url(url_options_for_protocol(:http).merge(:token => login.token)))
end
|
#register ⇒ Object
11
12
13
14
|
# File 'app/controllers/cheapskate/application_controller.rb', line 11
def register
user = @client.create_user(params)
redirect_to(registered_url(url_options_for_protocol(:http)))
end
|