mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-16 15:20:13 +01:00
Coding style fixes
This commit is contained in:
parent
4fe600a916
commit
371f8d5adf
14 changed files with 132 additions and 179 deletions
|
|
@ -12,11 +12,11 @@ module LoginSystem
|
|||
# Logout the {#current_user} and redirect to login page
|
||||
#
|
||||
# @param [String] message notification to display
|
||||
def logout_user message=t('login.logged_out')
|
||||
def logout_user(message=t('login.logged_out'))
|
||||
@user.forget_me if logged_in?
|
||||
cookies.delete :auth_token
|
||||
session['user_id'] = nil
|
||||
if ( SITE_CONFIG['authentication_schemes'].include? 'cas') && session[:cas_user]
|
||||
if SITE_CONFIG['authentication_schemes'].include?('cas') && session[:cas_user]
|
||||
CASClient::Frameworks::Rails::Filter.logout(self)
|
||||
else
|
||||
reset_session
|
||||
|
|
@ -36,7 +36,7 @@ module LoginSystem
|
|||
# user.login != "bob"
|
||||
# end
|
||||
def authorize?(user)
|
||||
true
|
||||
true
|
||||
end
|
||||
|
||||
# overwrite this method if you only want to protect certain actions of the controller
|
||||
|
|
@ -78,7 +78,7 @@ module LoginSystem
|
|||
end
|
||||
# Allow also login based on auth data
|
||||
auth = get_basic_auth_data
|
||||
if user = User.where(:login => auth[:user], :token => auth[:pass]).first
|
||||
if (user = User.where(:login => auth[:user], :token => auth[:pass]).first)
|
||||
set_current_user(user)
|
||||
return true
|
||||
end
|
||||
|
|
@ -102,12 +102,12 @@ module LoginSystem
|
|||
|
||||
login_from_cookie
|
||||
|
||||
if session['user_id'] and authorize?(get_current_user)
|
||||
if session['user_id'] && authorize?(get_current_user)
|
||||
return true
|
||||
end
|
||||
|
||||
auth = get_basic_auth_data
|
||||
if user = User.authenticate(auth[:user], auth[:pass])
|
||||
if (user = User.authenticate(auth[:user], auth[:pass]))
|
||||
session['user_id'] = user.id
|
||||
set_current_user(user)
|
||||
return true
|
||||
|
|
@ -125,12 +125,12 @@ module LoginSystem
|
|||
def login_optional
|
||||
login_from_cookie
|
||||
|
||||
if session['user_id'] and authorize?(get_current_user)
|
||||
if session['user_id'] && authorize?(get_current_user)
|
||||
return true
|
||||
end
|
||||
|
||||
auth = get_basic_auth_data
|
||||
if user = User.authenticate(auth[:user], auth[:pass])
|
||||
if (user = User.authenticate(auth[:user], auth[:pass]))
|
||||
session['user_id'] = user.id
|
||||
set_current_user(user)
|
||||
return true
|
||||
|
|
@ -197,7 +197,7 @@ module LoginSystem
|
|||
authdata = request.env[location].to_s.split
|
||||
end
|
||||
end
|
||||
if authdata and authdata[0] == 'Basic'
|
||||
if authdata && authdata[0] == 'Basic'
|
||||
data = Base64.decode64(authdata[1]).split(':')[0..1]
|
||||
{
|
||||
user: data[0],
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
namespace :ci do
|
||||
desc 'Continuous integration tests, without features'
|
||||
task :lite do
|
||||
ENV['RAILS_ENV'] ||= "test"
|
||||
ENV['RAILS_ENV'] ||= "test"
|
||||
|
||||
puts 'Running "lite" test suite'
|
||||
|
||||
|
|
|
|||
|
|
@ -2,20 +2,20 @@ namespace :tracks do
|
|||
desc 'Replace the password of USER with a new one.'
|
||||
task :password => :environment do
|
||||
require "io/console"
|
||||
|
||||
|
||||
user = User.find_by_login(ENV['USER'])
|
||||
if user.nil?
|
||||
puts "Sorry, we couldn't find user '#{ENV['USER']}'. To specify a different user, pass USER=username to this task."
|
||||
exit 0
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
puts "Changing Tracks password for #{ENV['USER']}."
|
||||
print "New password: "
|
||||
password = STDIN.noecho(&:gets).chomp
|
||||
print "\nRetype new password: "
|
||||
password_confirmation = STDIN.noecho(&:gets).chomp
|
||||
puts
|
||||
|
||||
|
||||
begin
|
||||
user.change_password(password, password_confirmation)
|
||||
puts "Password changed."
|
||||
|
|
@ -25,4 +25,3 @@ namespace :tracks do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ module Tracks
|
|||
module SourceViewSwitching
|
||||
class Responder
|
||||
def initialize(source_view)
|
||||
@source_view = source_view.underscore.gsub(/\s+/,'_').to_sym rescue nil
|
||||
@source_view = source_view.underscore.gsub(/\s+/, '_').to_sym rescue nil
|
||||
end
|
||||
|
||||
def nil?
|
||||
|
|
@ -41,7 +41,7 @@ module Tracks
|
|||
|
||||
module Helper
|
||||
def source_view_tag(name)
|
||||
hidden_field_tag :_source_view, name.underscore.gsub(/\s+/,'_')
|
||||
hidden_field_tag :_source_view, name.underscore.gsub(/\s+/, '_')
|
||||
end
|
||||
|
||||
def source_view_is(s)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue