parent
8b94d283fb
commit
d7dc84439c
@ -0,0 +1,24 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class AuthorizeFollowController < ApplicationController
|
||||||
|
layout 'public'
|
||||||
|
|
||||||
|
before_action :authenticate_user!
|
||||||
|
|
||||||
|
def new
|
||||||
|
@account = FollowRemoteAccountService.new.call(params[:acct])
|
||||||
|
render :error if @account.nil?
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
@account = FollowService.new.call(current_account, params[:acct]).try(:target_account)
|
||||||
|
|
||||||
|
if @account.nil?
|
||||||
|
render :error
|
||||||
|
else
|
||||||
|
redirect_to web_url("accounts/#{@account.id}")
|
||||||
|
end
|
||||||
|
rescue ActiveRecord::RecordNotFound, Mastodon::NotPermitted
|
||||||
|
render :error
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,2 @@
|
|||||||
|
module AuthorizeFollowHelper
|
||||||
|
end
|
@ -0,0 +1,3 @@
|
|||||||
|
.form-container
|
||||||
|
.flash-message#error_explanation
|
||||||
|
= t('authorize_follow.error')
|
@ -0,0 +1,21 @@
|
|||||||
|
- content_for :page_title do
|
||||||
|
= t('authorize_follow.title', acct: @account.acct)
|
||||||
|
|
||||||
|
.form-container
|
||||||
|
.follow-prompt
|
||||||
|
%h2= t('authorize_follow.prompt_html', self: current_account.username)
|
||||||
|
|
||||||
|
.account-card
|
||||||
|
.detailed-status__display-name
|
||||||
|
%div
|
||||||
|
= image_tag @account.avatar.url(:original), alt: '', width: 48, height: 48, class: 'avatar'
|
||||||
|
|
||||||
|
%span.display-name
|
||||||
|
%strong= display_name(@account)
|
||||||
|
%span= "@#{@account.acct}"
|
||||||
|
|
||||||
|
.account__header__content= Formatter.instance.simplified_format(@account)
|
||||||
|
|
||||||
|
= form_tag authorize_follow_path, method: :post, class: 'simple_form' do
|
||||||
|
= hidden_field_tag :acct, @account.acct
|
||||||
|
= button_tag t('authorize_follow.follow'), type: :submit
|
@ -1,2 +1,3 @@
|
|||||||
.flash-message#error_explanation
|
.form-container
|
||||||
= @pre_auth.error_response.body[:error_description]
|
.flash-message#error_explanation
|
||||||
|
= @pre_auth.error_response.body[:error_description]
|
||||||
|
@ -1,25 +1,26 @@
|
|||||||
- content_for :page_title do
|
- content_for :page_title do
|
||||||
= t('doorkeeper.authorizations.new.title')
|
= t('doorkeeper.authorizations.new.title')
|
||||||
|
|
||||||
.oauth-prompt
|
.form-container
|
||||||
%h2= t('doorkeeper.authorizations.new.prompt', client_name: @pre_auth.client.name)
|
.oauth-prompt
|
||||||
|
%h2= t('doorkeeper.authorizations.new.prompt', client_name: @pre_auth.client.name)
|
||||||
|
|
||||||
%p
|
%p
|
||||||
= t('doorkeeper.authorizations.new.able_to')
|
= t('doorkeeper.authorizations.new.able_to')
|
||||||
= @pre_auth.scopes.map { |scope| t(scope, scope: [:doorkeeper, :scopes]) }.map { |s| "<strong>#{s}</strong>"}.to_sentence.html_safe
|
= @pre_auth.scopes.map { |scope| t(scope, scope: [:doorkeeper, :scopes]) }.map { |s| "<strong>#{s}</strong>"}.to_sentence.html_safe
|
||||||
|
|
||||||
= form_tag oauth_authorization_path, method: :post, class: 'simple_form' do
|
= form_tag oauth_authorization_path, method: :post, class: 'simple_form' do
|
||||||
= hidden_field_tag :client_id, @pre_auth.client.uid
|
= hidden_field_tag :client_id, @pre_auth.client.uid
|
||||||
= hidden_field_tag :redirect_uri, @pre_auth.redirect_uri
|
= hidden_field_tag :redirect_uri, @pre_auth.redirect_uri
|
||||||
= hidden_field_tag :state, @pre_auth.state
|
= hidden_field_tag :state, @pre_auth.state
|
||||||
= hidden_field_tag :response_type, @pre_auth.response_type
|
= hidden_field_tag :response_type, @pre_auth.response_type
|
||||||
= hidden_field_tag :scope, @pre_auth.scope
|
= hidden_field_tag :scope, @pre_auth.scope
|
||||||
= button_tag t('doorkeeper.authorizations.buttons.authorize'), type: :submit
|
= button_tag t('doorkeeper.authorizations.buttons.authorize'), type: :submit
|
||||||
|
|
||||||
= form_tag oauth_authorization_path, method: :delete, class: 'simple_form' do
|
= form_tag oauth_authorization_path, method: :delete, class: 'simple_form' do
|
||||||
= hidden_field_tag :client_id, @pre_auth.client.uid
|
= hidden_field_tag :client_id, @pre_auth.client.uid
|
||||||
= hidden_field_tag :redirect_uri, @pre_auth.redirect_uri
|
= hidden_field_tag :redirect_uri, @pre_auth.redirect_uri
|
||||||
= hidden_field_tag :state, @pre_auth.state
|
= hidden_field_tag :state, @pre_auth.state
|
||||||
= hidden_field_tag :response_type, @pre_auth.response_type
|
= hidden_field_tag :response_type, @pre_auth.response_type
|
||||||
= hidden_field_tag :scope, @pre_auth.scope
|
= hidden_field_tag :scope, @pre_auth.scope
|
||||||
= button_tag t('doorkeeper.authorizations.buttons.deny'), type: :submit, class: 'negative'
|
= button_tag t('doorkeeper.authorizations.buttons.deny'), type: :submit, class: 'negative'
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
.flash-message
|
.form-container
|
||||||
%code= params[:code]
|
.flash-message
|
||||||
|
%code= params[:code]
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe AuthorizeFollowController, type: :controller do
|
||||||
|
describe 'GET #new'
|
||||||
|
describe 'POST #create'
|
||||||
|
end
|
@ -0,0 +1,5 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe AuthorizeFollowHelper, type: :helper do
|
||||||
|
|
||||||
|
end
|
Loading…
Reference in new issue