5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-17 13:16:21 +00:00

fix: change token attribute from encrypted to normal in Rol model #13903

This commit is contained in:
jazzari 2023-08-10 16:05:14 -03:00
parent c19c834f10
commit 705d15c0c1
2 changed files with 17 additions and 6 deletions

View file

@ -2,19 +2,31 @@
module Api
module V1
# Recibe webhooks y lanza jobs
# Recibe webhooks y lanza un PullJob
class WebhooksController < BaseController
rescue_from ActiveRecord::RecordNotFound, with: :platforms_answer
def site
@site ||= Site.find_by_name!(params[:site_id])
end
# valida la plataforma del webhook
def usuarie
# Gitlab
token = request.headers["X-Gitlab-Token"]
@usuarie = site.roles.find_by!(temporal: false, rol: 'usuarie', token: token).usuarie
end
# Trae los cambios a partir de un post de Webhooks:
# (Gitlab, Github, Guitea, etc)
def pull
site = Site.find_by_name!(params[:site_id])
usuarie = GitAuthor.new email: "webhook@#{Site.domain}", name: 'Webhook'
message = I18n.with_locale(site.default_locale) do
I18n.t('webhooks.pull.message')
end
GitPullJob.perform_later(site, usuarie, message)
end
def platforms_answer
head :ok
end
end

View file

@ -14,7 +14,6 @@ class Rol < ApplicationRecord
validates_inclusion_of :rol, in: ROLES
encrypts :token
before_save :add_token_if_missing!
def invitade?