Created
April 16, 2014 14:03
-
-
Save dhh/10880690 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UserAuthenticationsController < AuthenticatedController | |
def create | |
if authenticate | |
enroll_promotions | |
redirect_to return_path | |
else | |
redirect_to back_path, error: authentication_error_message | |
end | |
end | |
private | |
def authenticate | |
if user_authentication.authenticate!(sso_session).success? | |
self.current_token = user_authentication.authenticated_user_token | |
end | |
end | |
def enroll_promotions | |
if user_authentication.promo_applicable? | |
user_authentication.enroll! promo_id | |
flash[:success] = I18n.t("promotions.confirmation_message") | |
end | |
end | |
def authentication_error_message | |
I18n.t("user_authentication.not_allowed") if user_authentication.not_allowed? | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment