Skip to content
This repository has been archived by the owner on Jul 24, 2020. It is now read-only.

Commit

Permalink
Actually fix authentication initializer
Browse files Browse the repository at this point in the history
Resolves #1324 (and #1282 for real)
- ensures that authentication initializer actually runs
- ensures that username is copied to cas_login during migration if
  necessary
  • Loading branch information
orenyk committed Oct 20, 2015
1 parent d91e4e9 commit f97e9f9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion config/initializers/authentication.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Check for authentication method and copy data over if necessary (ENV variable
# to skip if necessary, skip if migrating from a pre-v4.1.0 DB or no table)
unless ENV['SKIP_AUTH_INIT'] || !User.table_exists? ||
!User.respond_to?(:username)
!User.column_names.include?('username')

user = User.first

Expand Down
6 changes: 6 additions & 0 deletions db/migrate/20150323013431_add_cas_login_to_users.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
class AddCasLoginToUsers < ActiveRecord::Migration
def change
add_column :users, :cas_login, :string

# copy username to cas_login if you use CAS already
if ENV['CAS_AUTH']
ActiveRecord::Base.connection
.execute('update users set cas_login=username')
end
end
end

0 comments on commit f97e9f9

Please sign in to comment.