parent
34febf75be
commit
57f6f80838
@ -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
|
||||
.flash-message#error_explanation
|
||||
= @pre_auth.error_response.body[:error_description]
|
||||
|
@ -1,2 +1,3 @@
|
||||
.flash-message
|
||||
.form-container
|
||||
.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