From 09ba5c9be8f095d4a546f1ad7bcd977f635a87d4 Mon Sep 17 00:00:00 2001 From: Fosco Marotto Date: Sun, 14 Feb 2021 14:05:03 -0500 Subject: [PATCH] Fix settings application controller writing role --- app/models/user.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 6f536e17..28c3302d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -213,12 +213,14 @@ class User < ApplicationRecord def token_for_app(a) return nil if a.nil? || a.owner != self - Doorkeeper::AccessToken - .find_or_create_by(application_id: a.id, resource_owner_id: id) do |t| + ActiveRecord::Base.connected_to(role: :writing) do + Doorkeeper::AccessToken + .find_or_create_by(application_id: a.id, resource_owner_id: id) do |t| - t.scopes = a.scopes - t.expires_in = Doorkeeper.configuration.access_token_expires_in - t.use_refresh_token = Doorkeeper.configuration.refresh_token_enabled? + t.scopes = a.scopes + t.expires_in = Doorkeeper.configuration.access_token_expires_in + t.use_refresh_token = Doorkeeper.configuration.refresh_token_enabled? + end end end