mirror of https://github.com/mastodon/mastodon
registration APIpull/69/head
parent
210362e665
commit
7e14eefc81
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
@ -0,0 +1,13 @@
|
||||
class Api::AppsController < ApplicationController
|
||||
respond_to :json
|
||||
|
||||
def create
|
||||
@app = Doorkeeper::Application.create!(app_params)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def app_params
|
||||
params.permit(:name, :redirect_uri)
|
||||
end
|
||||
end
|
@ -1,18 +0,0 @@
|
||||
class Oauth::ApplicationsController < Doorkeeper::ApplicationsController
|
||||
before_action :authenticate_user!
|
||||
|
||||
def index
|
||||
@applications = current_user.oauth_applications
|
||||
end
|
||||
|
||||
def create
|
||||
@application = Doorkeeper::Application.new(application_params)
|
||||
@application.owner = current_user
|
||||
|
||||
if @application.save
|
||||
redirect_to oauth_application_url(@application)
|
||||
else
|
||||
render :new
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,2 @@
|
||||
module Api::AppsHelper
|
||||
end
|
@ -1,2 +0,0 @@
|
||||
module Oauth::ApplicationsHelper
|
||||
end
|
@ -0,0 +1,12 @@
|
||||
class UnfavouriteService < BaseService
|
||||
def call(account, status)
|
||||
favourite = Favourite.find_by!(account: account, status: status)
|
||||
favourite.destroy!
|
||||
|
||||
unless status.local?
|
||||
NotificationWorker.perform_async(favourite.stream_entry.id, status.account_id)
|
||||
end
|
||||
|
||||
favourite
|
||||
end
|
||||
end
|
@ -0,0 +1,4 @@
|
||||
object @app
|
||||
attributes :id, :redirect_uri
|
||||
node(:client_id) { |app| app.uid }
|
||||
node(:client_secret) { |app| app.secret }
|
@ -1,11 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="<%= dim %>" height="<%= dim %>" class="mastodon" viewBox="-100 0 1390 750">
|
||||
<circle cx="600" cy="380" r="500" fill="#9baec8" class="mastodon-backdrop"/>
|
||||
<path fill="#282c37" d="M500 200l130-60h140l160 130-90 160-250 45-150-24-26 56 16 83h60l10 40-50 50-80-40-60-160 90-180" class="mastodon-shape" id="mastodon-head-backdrop"/>
|
||||
<path fill="#282c37" d="M442.1204 451.3337l-42.08-151.3737-.0425.0424-89.993 180.007 60.002 159.9848 80.003 40.0015 49.9913-49.9913-10.011-40.0015h-59.981l-16.0134-82.994 26.003-56.015 2.121.3393z" class="mastodon-shape" id="mastodon-nose"/>
|
||||
<path fill="#282c37" d="M498.2625 201.7378L400.0403 299.96l42.08 151.3737 147.8742 23.67.5515-.106-92.2835-273.16z" class="mastodon-shape" id="mastodon-cheek"/>
|
||||
<path fill="#282c37" d="M498.2625 201.7378l92.2835 273.16.7635-.1273L770.0862 140.06l-.0848-.0637H629.996l-129.9943 60.0023-1.7392 1.7392z" class="mastodon-shape" id="mastodon-forehead"/>
|
||||
<path fill="#282c37" d="M770.0862 140.06L591.3095 474.7705l248.684-44.7737 90.014-160.006L770.0862 140.06z" class="mastodon-shape" id="mastodon-backhead"/>
|
||||
<path fill="#fff" d="M440 450l-40 80-170-20L70 390-80 230 0 390l100 100 120 100 120 20h130l90-140" class="mastodon-shape" id="mastodon-tusk-front"/>
|
||||
<path fill="#d9e1e8" d="M268 516L120 360 80 260l70 90 110 90 59 22-8 18 15 41" class="mastodon-shape" id="mastodon-tusk-back"/>
|
||||
<path fill="#282c37" d="M780 190l110 80-80 140-40-80" class="mastodon-shape" id="mastodon-ear"/>
|
||||
</svg>
|
Before Width: | Height: | Size: 1.5 KiB |
@ -0,0 +1,7 @@
|
||||
class RemoveOwnerFromApplication < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
remove_index :oauth_applications, [:owner_id, :owner_type]
|
||||
remove_column :oauth_applications, :owner_id, :integer, null: true
|
||||
remove_column :oauth_applications, :owner_type, :string, null: true
|
||||
end
|
||||
end
|
Binary file not shown.
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 927 B |
@ -0,0 +1,26 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Api::AppsController, type: :controller do
|
||||
render_views
|
||||
|
||||
describe 'POST #create' do
|
||||
before do
|
||||
post :create, params: { name: 'Test app', redirect_uri: 'urn:ietf:wg:oauth:2.0:oob' }
|
||||
end
|
||||
|
||||
it 'returns http success' do
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
|
||||
it 'creates an OAuth app' do
|
||||
expect(Doorkeeper::Application.find_by(name: 'Test app')).to_not be nil
|
||||
end
|
||||
|
||||
it 'returns client ID and client secret' do
|
||||
json = body_as_json
|
||||
|
||||
expect(json[:client_id]).to_not be_blank
|
||||
expect(json[:client_secret]).to_not be_blank
|
||||
end
|
||||
end
|
||||
end
|
@ -1,18 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Oauth::ApplicationsController, type: :controller do
|
||||
before do
|
||||
sign_in Fabricate(:user), scope: :user
|
||||
end
|
||||
|
||||
describe 'GET #index' do
|
||||
it 'returns http success' do
|
||||
get :index
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #create' do
|
||||
it 'redirects to the application page'
|
||||
end
|
||||
end
|
@ -0,0 +1,15 @@
|
||||
require 'rails_helper'
|
||||
|
||||
# Specs in this file have access to a helper object that includes
|
||||
# the Api::AppsHelper. For example:
|
||||
#
|
||||
# describe Api::AppsHelper do
|
||||
# describe "string concat" do
|
||||
# it "concats two strings with spaces" do
|
||||
# expect(helper.concat_strings("this","that")).to eq("this that")
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
RSpec.describe Api::AppsHelper, type: :helper do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
@ -1,5 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Oauth::ApplicationsHelper, type: :helper do
|
||||
|
||||
end
|
Loading…
Reference in New Issue