dev_forum
cxt 6 years ago
parent ae8dadba6d
commit c25d89db75

@ -72,6 +72,15 @@ class AccountsController < ApplicationController
# 用户登录
def login
@user = User.try_to_login(params[:login], params[:password])
if @user
# user is already in local database
return normal_status(-2, "违反平台使用规范,账号已被锁定") if @user.locked?
return normal_status(-2, "错误的账号或密码") unless @user.check_password?(params[:password].to_s)
else
return normal_status(-2, "错误的账号或密码")
end
@user.update_column(:last_login_on, Time.now)
successful_authentication(@user)

@ -507,14 +507,6 @@ class User < ApplicationRecord
user = find_by_login(login)
end
if user
# user is already in local database
raise Educoder::TipException.new(-2, "违反平台使用规范,账号已被锁定") if user.locked?
raise Educoder::TipException.new(-2, "错误的账号或密码") unless user.check_password?(password)
else
raise Educoder::TipException.new(-2, "错误的账号或密码")
end
user
rescue => text
raise text

Loading…
Cancel
Save