class UserController < ApplicationController
layout :choose_layout
+ before_filter :disable_terms_redirect, :only => [:terms, :save, :logout, :api_details]
before_filter :authorize, :only => [:api_details, :api_gpx_files]
before_filter :authorize_web, :except => [:api_details, :api_gpx_files]
before_filter :set_locale, :except => [:api_details, :api_gpx_files]
elsif params[:decline]
if @user
@user.terms_seen = true
- @user.save
+
+ if @user.save
+ flash[:notice] = t 'user.new.terms declined', :url => t('user.new.terms declined url')
+ end
if params[:referer]
redirect_to params[:referer]
if token
token.destroy
end
- session[:token] = nil
+ session.delete(:token)
end
- session[:user] = nil
+ session.delete(:user)
session_expires_automatically
if params[:referer]
redirect_to params[:referer]
# Choose the layout to use. See
# https://rails.lighthouseapp.com/projects/8994/tickets/5371-layout-with-onlyexcept-options-makes-other-actions-render-without-layouts
def choose_layout
+ oauth_url = url_for(:controller => :oauth, :action => :oauthorize, :only_path => true)
+
if [ 'api_details' ].include? action_name
nil
- elsif params[:referer] == url_for(:controller => :oauth, :action => :oauthorize, :only_path => true)
+ elsif params[:referer] and URI.parse(params[:referer]).path == oauth_url
'slim'
else
'site'
end
end
+
+ ##
+ #
+ def disable_terms_redirect
+ # this is necessary otherwise going to the user terms page, when
+ # having not agreed already would cause an infinite redirect loop.
+ # it's .now so that this doesn't propagate to other pages.
+ flash.now[:skip_terms] = true
+ end
end