add login by giteatoken

This commit is contained in:
chenjing 2022-06-23 16:15:03 +08:00
parent 8670bcf95c
commit aaeec77d23
2 changed files with 10 additions and 1 deletions

View File

@ -88,4 +88,13 @@ class OauthController < ApplicationController
end
end
def token_login
@user = User.find_by_gitea_token(params[:token])
if @user.present?
successful_authentication(@user)
redirect_to root_url
else
render json: { error: "用户不存在" }
end
end
end

View File

@ -938,7 +938,7 @@ Rails.application.routes.draw do
get 'oauth/get_code', to: 'oauth#get_code'
get 'oauth/get_token_callback', to: 'oauth#get_token_callback'
get 'oauth/token_login', to: 'oauth#token_login'
root 'main#index'