From a8fb7072305beaf3fd83a10fe720504588acb9e0 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 19 Mar 2019 16:19:06 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E5=8A=A8=E5=90=8C=E6=AD=A5=E8=BF=87?= =?UTF-8?q?=E6=9D=A5=E7=9A=84=E6=89=8B=E6=9C=BA=E5=8F=B7=E6=9C=89=E7=9B=B8?= =?UTF-8?q?=E5=90=8C=E7=9A=84=E6=83=85=E5=86=B5=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/ecloud_controller.rb | 2 +- app/models/user.rb | 38 ++++++++++++++++------------ 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/app/controllers/ecloud_controller.rb b/app/controllers/ecloud_controller.rb index c49b34a6..6ff6d1ef 100644 --- a/app/controllers/ecloud_controller.rb +++ b/app/controllers/ecloud_controller.rb @@ -43,7 +43,7 @@ class EcloudController < ApplicationController CLIENT_ID = '1056' CLIENT_SECRET = '2e84256a-3de4-4713-9e02-10ee88a14592' SERVER_URL = "https://221.176.53.130:44390/services/" - +q ## 签名 diff --git a/app/models/user.rb b/app/models/user.rb index fdb9566a..31c58f26 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1693,31 +1693,37 @@ class User < Principal end def self.create_with_ecoder!(info) - user = User.new - user.admin = false - user.login = "ecoder_" + info["mobile"] + user = User.find_by_phone(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.mail = info["email"] - end - user.nickname = info["username"] + user.phone = info["mobile"] + + unless User.find_by_mail(info["email"]) + user.mail = info["email"] + end + user.nickname = info["username"] - user.activate - user.last_login_on = Time.now + user.activate + 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_id = user.id - ue.save! + ue = user.user_extensions ||= UserExtensions.new + ue.user_id = user.id + ue.save! + end user end