|
|
@ -1693,31 +1693,37 @@ class User < Principal
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def self.create_with_ecoder!(info)
|
|
|
|
def self.create_with_ecoder!(info)
|
|
|
|
user = User.new
|
|
|
|
user = User.find_by_phone(info["mobile"])
|
|
|
|
user.admin = false
|
|
|
|
|
|
|
|
user.login = "ecoder_" + info["mobile"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
user.phone = info["mobile"]
|
|
|
|
# 如果手机号存在,则直接绑定用户
|
|
|
|
|
|
|
|
# 因为手机号可以取回密码,所以可以视为同一用户
|
|
|
|
|
|
|
|
unless user
|
|
|
|
|
|
|
|
user = User.new
|
|
|
|
|
|
|
|
user.admin = false
|
|
|
|
|
|
|
|
user.login = "ecoder_" + info["mobile"]
|
|
|
|
|
|
|
|
|
|
|
|
unless User.find_by_mail(info["email"])
|
|
|
|
user.phone = info["mobile"]
|
|
|
|
user.mail = info["email"]
|
|
|
|
|
|
|
|
end
|
|
|
|
unless User.find_by_mail(info["email"])
|
|
|
|
user.nickname = info["username"]
|
|
|
|
user.mail = info["email"]
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
user.nickname = info["username"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
user.activate
|
|
|
|
user.activate
|
|
|
|
user.last_login_on = Time.now
|
|
|
|
user.last_login_on = Time.now
|
|
|
|
|
|
|
|
|
|
|
|
user.ecoder_user_id = info["userid"]
|
|
|
|
user.ecoder_user_id = info["userid"]
|
|
|
|
|
|
|
|
|
|
|
|
user.save!(:validate => false)
|
|
|
|
user.save!(:validate => false)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UserStatus.create!(:user_id => user.id, :changsets_count => 0, :watchers_count => 0)
|
|
|
|
UserStatus.create!(:user_id => user.id, :changsets_count => 0, :watchers_count => 0)
|
|
|
|
|
|
|
|
|
|
|
|
ue = user.user_extensions ||= UserExtensions.new
|
|
|
|
ue = user.user_extensions ||= UserExtensions.new
|
|
|
|
ue.user_id = user.id
|
|
|
|
ue.user_id = user.id
|
|
|
|
ue.save!
|
|
|
|
ue.save!
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
user
|
|
|
|
user
|
|
|
|
end
|
|
|
|
end
|
|
|
|