Browse Source

修改同步登录的接口

tags/v1
sylor_huang@126.com 6 years ago
parent
commit
c88ba4a4d3
2 changed files with 12 additions and 3 deletions
  1. +11
    -3
      app/controllers/accounts_controller.rb
  2. +1
    -0
      config/routes.rb

+ 11
- 3
app/controllers/accounts_controller.rb View File

@@ -72,6 +72,17 @@ class AccountsController < ApplicationController
tip_exception(-1, e.message)
end
# 其他平台同步登录
def remote_login
@user = User.try_to_login(params[:login], params[:password])
if @user
successful_authentication(@user)
render_ok({user: {id: @user.id, token: @user.gitea_token}})
else
render_error("用户不存在")
end
end
# 用户注册
@@ -162,9 +173,6 @@ class AccountsController < ApplicationController
end
successful_authentication(@user)
login_control.clear # 重置每日密码错误次数
Rails.logger.info("#########_______User_current_id________#############{User.current.try(:id)}")
Rails.logger.info("#########_______current_user_id________#############{current_user.try(:id)}")
# session[:user_id] = @user.id
end


+ 1
- 0
config/routes.rb View File

@@ -123,6 +123,7 @@ Rails.application.routes.draw do
get :valid_email_and_phone
post :remote_register
post :remote_update
post :remote_login
end
end


Loading…
Cancel
Save