|
|
|
@ -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)
|
|
|
|
|