-
-
Save foucist/817cdc2a5ec2456fc515 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
case @current_profile | |
when lambda(&:nil?) | |
throw :halt, render(json_error_response(:status_code => ERROR_LOGIN_REQUIRED, :message => _('You need to be logged in.'))) | |
when lambda(&:deleted?) | |
session.clear! | |
throw :halt, render(json_error_response(ERROR_NOT_PERMITTED, :message => _('Your account has been deleted. Please create a new account.'))) | |
when lambda(&:suspended?) | |
current_profile.track_action(:logout, :suspended => true) | |
logout! | |
throw :halt, render(json_error_response(ERROR_NOT_PERMITTED, :message => _('Access Status - Suspended'))) | |
end | |
# versus | |
if @current_profile.nil? | |
throw :halt, render(json_error_response(:status_code => ERROR_LOGIN_REQUIRED, :message => _('You need to be logged in.'))) | |
elsif @current_profile.deleted? | |
session.clear! | |
throw :halt, render(json_error_response(ERROR_NOT_PERMITTED, :message => _('Your account has been deleted. Please create a new account.'))) | |
elsif @current_profile.suspended? | |
current_profile.track_action(:logout, :suspended => true) | |
logout! | |
throw :halt, render(json_error_response(ERROR_NOT_PERMITTED, :message => _('Access Status - Suspended'))) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment