Corrections auto avec standardrb
parent
b27a63ba9c
commit
2dc085be6f
@ -1,28 +1,28 @@
|
||||
class Api::V1::ApiKeysController < Api::V1::BaseController
|
||||
# Require API key authentication
|
||||
prepend_before_action :authenticate_with_api_key!, only: %i[index destroy]
|
||||
# Require API key authentication
|
||||
prepend_before_action :authenticate_with_api_key!, only: %i[index destroy]
|
||||
|
||||
def index
|
||||
render json: current_bearer.api_keys
|
||||
end
|
||||
def index
|
||||
render json: current_bearer.api_keys
|
||||
end
|
||||
|
||||
def create
|
||||
authenticate_with_http_basic do |email, password|
|
||||
user = User.find_by email: email
|
||||
def create
|
||||
authenticate_with_http_basic do |email, password|
|
||||
user = User.find_by email: email
|
||||
|
||||
if user&.authenticate(password)
|
||||
api_key = user.api_keys.create! token: SecureRandom.hex
|
||||
if user&.authenticate(password)
|
||||
api_key = user.api_keys.create! token: SecureRandom.hex
|
||||
|
||||
render json: api_key, status: :created and return
|
||||
end
|
||||
render json: api_key, status: :created and return
|
||||
end
|
||||
|
||||
render status: :unauthorized
|
||||
end
|
||||
|
||||
def destroy
|
||||
api_key = current_bearer.api_keys.find(params[:id])
|
||||
render status: :unauthorized
|
||||
end
|
||||
|
||||
api_key.destroy
|
||||
end
|
||||
end
|
||||
def destroy
|
||||
api_key = current_bearer.api_keys.find(params[:id])
|
||||
|
||||
api_key.destroy
|
||||
end
|
||||
end
|
||||
|
@ -1,3 +1,3 @@
|
||||
class AuthenticatedController < ApplicationController
|
||||
before_action :authenticate_user!
|
||||
end
|
||||
before_action :authenticate_user!
|
||||
end
|
||||
|
@ -1,28 +1,26 @@
|
||||
module ApplicationHelper
|
||||
def colored_pill_tag(content_or_options_with_block = nil, options = nil, &block)
|
||||
if block
|
||||
options = content_or_options_with_block if content_or_options_with_block.is_a?(Hash)
|
||||
end
|
||||
|
||||
def colored_pill_tag(content_or_options_with_block = nil, options = nil, &block)
|
||||
if block_given?
|
||||
options = content_or_options_with_block if content_or_options_with_block.is_a?(Hash)
|
||||
end
|
||||
|
||||
color_classes = case options.fetch(:color)
|
||||
when "red"
|
||||
"bg-red-100 text-red-800"
|
||||
when "green"
|
||||
"bg-green-100 text-green-800"
|
||||
when "orange"
|
||||
"bg-orange-100 text-orange-800"
|
||||
else
|
||||
"bg-gray-100 text-gray-800"
|
||||
end
|
||||
|
||||
classes = "px-2 inline-flex text-xs leading-5 font-semibold rounded-full #{color_classes}"
|
||||
color_classes = case options.fetch(:color)
|
||||
when "red"
|
||||
"bg-red-100 text-red-800"
|
||||
when "green"
|
||||
"bg-green-100 text-green-800"
|
||||
when "orange"
|
||||
"bg-orange-100 text-orange-800"
|
||||
else
|
||||
"bg-gray-100 text-gray-800"
|
||||
end
|
||||
|
||||
if block_given?
|
||||
content_tag(:span, class: classes, &block)
|
||||
else
|
||||
content_tag(:span, content_or_options_with_block, class: classes)
|
||||
end
|
||||
classes = "px-2 inline-flex text-xs leading-5 font-semibold rounded-full #{color_classes}"
|
||||
|
||||
if block
|
||||
content_tag(:span, class: classes, &block)
|
||||
else
|
||||
content_tag(:span, content_or_options_with_block, class: classes)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,10 +1,10 @@
|
||||
module UsersHelper
|
||||
def user_gravatar(user, options = {})
|
||||
options = {:alt => 'avatar', :class => 'avatar', :size => 80}.merge! options
|
||||
id = Digest::MD5::hexdigest(user.email.strip.downcase)
|
||||
url = 'http://www.gravatar.com/avatar/' + id + '.jpg?s=' + options[:size].to_s
|
||||
options = {alt: "avatar", class: "avatar", size: 80}.merge! options
|
||||
id = Digest::MD5.hexdigest(user.email.strip.downcase)
|
||||
url = "http://www.gravatar.com/avatar/" + id + ".jpg?s=" + options[:size].to_s
|
||||
options.delete :size
|
||||
|
||||
image_tag(url, options)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,4 +1,4 @@
|
||||
class Check < ApplicationRecord
|
||||
validates_presence_of :name
|
||||
validates_presence_of :hostname
|
||||
validates_presence_of :name
|
||||
validates_presence_of :hostname
|
||||
end
|
||||
|
@ -1,8 +1,8 @@
|
||||
class CheckReport
|
||||
include ActiveModel::API
|
||||
include ActiveModel::Attributes
|
||||
include ActiveModel::API
|
||||
include ActiveModel::Attributes
|
||||
|
||||
attribute :hostname, :string
|
||||
attribute :date, :datetime, default: -> { Time.now }
|
||||
attribute :checks, array: true
|
||||
attribute :hostname, :string
|
||||
attribute :date, :datetime, default: -> { Time.now }
|
||||
attribute :checks, array: true
|
||||
end
|
||||
|
@ -1,5 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
Heroicon.configure do |config|
|
||||
config.variant = :solid # Options are :solid and :outline
|
||||
end
|
||||
config.variant = :solid # Options are :solid and :outline
|
||||
end
|
||||
|
@ -1,4 +1,3 @@
|
||||
# Preview all emails at http://localhost:3000/rails/mailers/user_mailer
|
||||
class UserMailerPreview < ActionMailer::Preview
|
||||
|
||||
end
|
||||
|
Loading…
Reference in New Issue