mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-17 15:56:21 +00:00
fix: change token attribute from encrypted to normal in Rol model #13903
This commit is contained in:
parent
c19c834f10
commit
705d15c0c1
2 changed files with 17 additions and 6 deletions
|
@ -2,19 +2,31 @@
|
||||||
|
|
||||||
module Api
|
module Api
|
||||||
module V1
|
module V1
|
||||||
# Recibe webhooks y lanza jobs
|
# Recibe webhooks y lanza un PullJob
|
||||||
class WebhooksController < BaseController
|
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:
|
# Trae los cambios a partir de un post de Webhooks:
|
||||||
# (Gitlab, Github, Guitea, etc)
|
# (Gitlab, Github, Guitea, etc)
|
||||||
def pull
|
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
|
message = I18n.with_locale(site.default_locale) do
|
||||||
I18n.t('webhooks.pull.message')
|
I18n.t('webhooks.pull.message')
|
||||||
end
|
end
|
||||||
|
|
||||||
GitPullJob.perform_later(site, usuarie, message)
|
GitPullJob.perform_later(site, usuarie, message)
|
||||||
|
end
|
||||||
|
|
||||||
|
def platforms_answer
|
||||||
head :ok
|
head :ok
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,7 +14,6 @@ class Rol < ApplicationRecord
|
||||||
|
|
||||||
validates_inclusion_of :rol, in: ROLES
|
validates_inclusion_of :rol, in: ROLES
|
||||||
|
|
||||||
encrypts :token
|
|
||||||
before_save :add_token_if_missing!
|
before_save :add_token_if_missing!
|
||||||
|
|
||||||
def invitade?
|
def invitade?
|
||||||
|
|
Loading…
Reference in a new issue