diff --git a/app/controllers/oauth_controller.rb b/app/controllers/oauth_controller.rb index f2ca2cc2..5e243342 100644 --- a/app/controllers/oauth_controller.rb +++ b/app/controllers/oauth_controller.rb @@ -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 diff --git a/config/routes.rb b/config/routes.rb index e1058714..28a77f8e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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'