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