Implements iChain authentication
This commit is contained in:
parent
15c6ed127f
commit
49d565def2
21 changed files with 269 additions and 126 deletions
18
db/migrate/20141104131625_generate_username.rb
Normal file
18
db/migrate/20141104131625_generate_username.rb
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
class GenerateUsername < ActiveRecord::Migration
|
||||
class TempUser < ActiveRecord::Base
|
||||
self.table_name = 'users'
|
||||
attr_accessible :username, :email
|
||||
end
|
||||
|
||||
def change
|
||||
TempUser.all.each do |user|
|
||||
if user.username.blank?
|
||||
username = user.email.split('@')[0]
|
||||
if TempUser.find_by(username: username)
|
||||
username = username + user.id.to_s
|
||||
end
|
||||
user.update_attributes(username: username)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue