From f027b52e4a874bfd4ea9c6300cfdc9c5a513d9f0 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 27 May 2019 17:58:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A5=BD=E5=A4=A7=E5=AD=A6=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/cnmoocs_service.rb | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/app/services/cnmoocs_service.rb b/app/services/cnmoocs_service.rb index fbb8d55c..40f75a8c 100644 --- a/app/services/cnmoocs_service.rb +++ b/app/services/cnmoocs_service.rb @@ -37,9 +37,9 @@ class CnmoocsService def find_user params user = User.find_by_mail params[:mail] if user - {error: 0, message: "找到用户"} + {error: 0, messages: "找到用户"} else - {error: -1, message: "找不到用户"} + {error: -1, messages: "找不到用户"} end end @@ -55,16 +55,21 @@ class CnmoocsService user.save! UserExtensions.create!(user_id: user.id, school_id: School.first.id, identity: 4, gender: 0) end - {error: 0, message: "创建成功"} + {error: 0, messages: "创建成功"} else - {error: -1, message: "邮箱已经存在,请直接使用邮箱登录"} + {error: -1, messages: "邮箱已经存在,请直接使用邮箱登录"} end end def login_educoder params user, last_login_on = User.try_to_login(params[:mail], params[:password]) - self.logged_user = user - {error: 0, message: "登录成功"} + if user + self.logged_user = user + {error: 0, messages: "登录成功"} + else + {error: -1, messages: "登录失败,请检查邮箱和密码是否正确"} + end + end