Sito marketing, SEO, legal, live programmata e branding Match Live Tv.
Logo e favicon nel header, partite programmate su web e mobile, reset password, pagine FAQ/sitemap, privacy/termini GDPR e icona Android «Match Live Tv». Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -2,6 +2,27 @@ class Match < ApplicationRecord
|
||||
belongs_to :team
|
||||
has_many :stream_sessions, dependent: :destroy
|
||||
|
||||
ACTIVE_SESSION_STATUSES = %w[live connecting reconnecting paused].freeze
|
||||
|
||||
validates :opponent_name, presence: true
|
||||
validates :sets_to_win, numericality: { greater_than: 0, less_than: 6 }
|
||||
|
||||
scope :scheduled_upcoming, -> {
|
||||
where.not(scheduled_at: nil).where("scheduled_at >= ?", Time.current)
|
||||
}
|
||||
|
||||
scope :search_teams_or_opponents, lambda { |query|
|
||||
q = query.to_s.strip
|
||||
return all if q.blank?
|
||||
|
||||
term = "%#{sanitize_sql_like(q)}%"
|
||||
joins(:team).where(
|
||||
"teams.name ILIKE :term OR matches.opponent_name ILIKE :term",
|
||||
term: term
|
||||
)
|
||||
}
|
||||
|
||||
def broadcast_active?
|
||||
stream_sessions.where(status: ACTIVE_SESSION_STATUSES).exists?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -14,4 +14,32 @@ class User < ApplicationRecord
|
||||
def admin?
|
||||
role == "admin"
|
||||
end
|
||||
|
||||
def generate_password_reset!
|
||||
raw = SecureRandom.urlsafe_base64(32)
|
||||
update!(
|
||||
password_reset_digest: User.digest_token(raw),
|
||||
password_reset_sent_at: Time.current
|
||||
)
|
||||
raw
|
||||
end
|
||||
|
||||
def password_reset_expired?
|
||||
password_reset_sent_at.blank? ||
|
||||
password_reset_sent_at < MatchLiveTv.password_reset_expiry_hours.hours.ago
|
||||
end
|
||||
|
||||
def clear_password_reset!
|
||||
update!(password_reset_digest: nil, password_reset_sent_at: nil)
|
||||
end
|
||||
|
||||
def self.find_by_password_reset_token(token)
|
||||
return if token.blank?
|
||||
|
||||
find_by(password_reset_digest: User.digest_token(token))
|
||||
end
|
||||
|
||||
def self.digest_token(token)
|
||||
Digest::SHA256.hexdigest(token.to_s)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user