Skip to content

Instantly share code, notes, and snippets.

@foucist
Created March 10, 2014 16:49
Show Gist options
  • Save foucist/817cdc2a5ec2456fc515 to your computer and use it in GitHub Desktop.
Save foucist/817cdc2a5ec2456fc515 to your computer and use it in GitHub Desktop.
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