You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
11 lines
372 B
11 lines
372 B
# frozen_string_literal: true |
|
|
|
class WebPushKeyValidator < ActiveModel::Validator |
|
def validate(subscription) |
|
begin |
|
Webpush::Encryption.encrypt('validation_test', subscription.key_p256dh, subscription.key_auth) |
|
rescue ArgumentError, OpenSSL::PKey::EC::Point::Error |
|
subscription.errors.add(:base, I18n.t('crypto.errors.invalid_key')) |
|
end |
|
end |
|
end
|
|
|