This repository has been archived by the owner on May 2, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
1,192 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class Api::V1::ApiController < ActionController::Base | ||
|
||
skip_before_action :verify_authenticity_token | ||
|
||
private | ||
|
||
# Find the user that owns the access token | ||
def current_user | ||
User::User.find(doorkeeper_token.resource_owner_id) if doorkeeper_token | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
class Api::V1::Domains::RecordsController < Api::V1::ApiController | ||
include DomainAuthorization | ||
before_action do | ||
doorkeeper_authorize! :domains | ||
doorkeeper_authorize! :domains_records | ||
end | ||
|
||
before_action only: [:create, :update, :destroy] do | ||
doorkeeper_authorize! :domains_records_write | ||
end | ||
|
||
def index | ||
@records = current_domain.records | ||
end | ||
|
||
def create | ||
@record = Record.create(domain_id: current_domain.id, name: params["name"], type: params["type"], content: params["content"], ttl: params["ttl"], priority: params["priority"]) # standard:disable all | ||
render "show" | ||
end | ||
|
||
def show | ||
@record = Record.find(params[:id]) | ||
end | ||
|
||
def update | ||
@record = Record.find(params[:id]) | ||
|
||
(@record.type = params[:type]) if params[:type] | ||
(@record.name = params[:name]) if params[:name] | ||
(@record.content = params[:content]) if params[:content] | ||
(@record.ttl = params[:ttl]) if params[:ttl] | ||
(@record.priority = params[:priority]) if params[:priority] | ||
|
||
@record.save # standard:disable all | ||
|
||
render "show" | ||
end | ||
|
||
def destroy | ||
@record = Record.find(params[:id]) | ||
|
||
@record.destroy! #standard:disable all | ||
|
||
index | ||
render "index" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
class Api::V1::DomainsController < Api::V1::ApiController | ||
include DomainAuthorization | ||
before_action do | ||
doorkeeper_authorize! :domains | ||
end | ||
|
||
before_action only: [:create, :destroy] do | ||
doorkeeper_authorize! :domains_write | ||
end | ||
|
||
skip_before_action :authorize_domain, only: [:index, :create] | ||
|
||
def index | ||
@domains = Domain.where(user_users_id: current_user.id) | ||
if params[:records] | ||
doorkeeper_authorize!(:domains_records) | ||
end | ||
end | ||
|
||
def show | ||
@domain = Domain.find_by(host: params[:host]) | ||
if params[:records] | ||
doorkeeper_authorize!(:domains_records) | ||
end | ||
end | ||
|
||
def create | ||
@domain = Domain.new(host: params[:host], plan: params[:plan], provisional: true, user_users_id: current_user.id) | ||
if @domain.save | ||
render "show" | ||
else | ||
render json: @domain.errors, status: 418 | ||
end | ||
end | ||
|
||
def destroy | ||
@domain = Domain.find_by(host: params[:host]) | ||
@domain.destroy! | ||
|
||
index | ||
render "index" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
class Api::V1::UserController < Api::V1::ApiController | ||
before_action do | ||
doorkeeper_authorize! :user | ||
end | ||
|
||
def show | ||
if doorkeeper_token.scopes.exists?(:name) | ||
@name = current_user.name | ||
end | ||
|
||
if doorkeeper_token.scopes.exists?(:email) | ||
@email = current_user.email | ||
end | ||
|
||
@id = current_user.id | ||
@created_at = current_user.created_at | ||
@updated_at = current_user.updated_at | ||
@verified = current_user.verified | ||
|
||
if doorkeeper_token.scopes.exists?(:admin) | ||
@admin = current_user.admin | ||
end | ||
end | ||
|
||
def update | ||
redirected = false | ||
|
||
if params[:name] | ||
if doorkeeper_authorize! :name_write | ||
redirected = true | ||
else | ||
current_user.update!(name: params[:name]) | ||
end | ||
end | ||
|
||
if params[:email] | ||
if doorkeeper_authorize! :email_write | ||
redirected = true | ||
else | ||
current_user.update!(email: params[:email]) | ||
end | ||
end | ||
|
||
if !redirected | ||
show | ||
render "show" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
json.id d.id | ||
json.host d.host | ||
json.created_at d.created_at | ||
json.updated_at d.updated_at | ||
json.user_id d.user_users_id | ||
json.provisional d.provisional | ||
json.plan d.plan | ||
if records | ||
json.records d.records, partial: "records/record", as: :r | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
json.array! @domains, partial: "domain", as: :d, locals: {records: params[:records]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
json.id r.id | ||
json.name r.name | ||
json.content r.content | ||
json.type r.type | ||
json.ttl r.ttl | ||
json.domain_id r.domain_id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
json.array! @records, partial: "record", as: :r |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
json.partial! "record", r: @record |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
json.partial! "domain", d: @domain, records: params[:records] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
json.id @id | ||
|
||
if @name | ||
json.name @name | ||
end | ||
|
||
if @email | ||
json.email @email | ||
end | ||
|
||
if @admin | ||
json.admin @admin | ||
end | ||
|
||
json.verified @verified | ||
json.created_at @created_at | ||
json.updated_at @updated_at |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
<h1>Unsupported Browser</h1> | ||
|
||
<p>Your browser doesn't support passkeys, how you access your Obl.ong account. Please upgrade to a supported browser [list browsers]</p> | ||
<p>Your browser doesn't support passkeys, how you access your Obl.ong account. Please upgrade to a supported browser [list browsers]</p> | ||
|
||
<a href="<%= params[:returnpath]%>?force=true">Continue anyway</a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.