From 3d0fa0d50cfa67f11f40e5d59edf5a8824d09cca Mon Sep 17 00:00:00 2001 From: xxq250 Date: Thu, 16 Feb 2023 11:01:21 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4Bot=E6=8E=88=E6=9D=83?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/installations_controller.rb | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/app/controllers/installations_controller.rb b/app/controllers/installations_controller.rb index 6e66431be..88c43cf69 100644 --- a/app/controllers/installations_controller.rb +++ b/app/controllers/installations_controller.rb @@ -51,15 +51,14 @@ class InstallationsController < ApplicationController @install_bot = BotInstall.find params[:id] @bot = @install_bot.bot @application = Doorkeeper::Application.find_by(uid: @bot.client_id, secret: @bot.client_secret) - if @application.present? - # 给bot生成token,因为bot是机器人操作 - @access_token = Doorkeeper::AccessToken.create!({ :application_id => @application.id, - :resource_owner_id => @bot.uid, - :scopes => "public write", - :expires_in => "604800", - :use_refresh_token => true - }) - end + tip_exception("该Bot未激活") if @application.blank? + # 给bot生成token,因为bot是机器人操作 + @access_token = Doorkeeper::AccessToken.create!({ :application_id => @application.id, + :resource_owner_id => @bot.uid, + :scopes => "public write", + :expires_in => "604800", + :use_refresh_token => true + }) render_ok(token: @access_token.token) end