Skip to content

Commit 461b427

Browse files
authored
Merge pull request #115 from apidemy/fix-missing-strict-origin-policy-func
Fix using function _is_strict_origin_policy_enabled in BMI and SEP
2 parents a4f648c + 7dccf9b commit 461b427

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ def go_to_gateway_view(request):
293293
</p>
294294

295295
```python
296-
SECURE_REFERRER_POLICY = 'strict-origin-when-cross-origin'
296+
SECURE_REFERRER_POLICY = "strict-origin-when-cross-origin"
297297
```
298298

299299
<h3 dir="rtl"> انتخاب خودکار درگاه </h3>
@@ -500,7 +500,7 @@ pre-commit install
500500
* [ahmadrezanavaie](https://github.com/ahmadrezanavaie) رفع مشکل ترجمه
501501
* [zamoosh](https://github.com/zamoosh) اضافه کردن وضعیت های تراکنش در بانک ملت
502502
* [birddevelper](https://github.com/birddevelper) الزامی کردن وجود referrer برای درگاه بانک ملی
503-
503+
* [apidemy](https://github.com/apidemy) ریفکتور _is_strict_origin_policy_enabled و پیروی از DRY
504504
## License
505505

506506
The MIT License (MIT). Please see [License File](LICENSE) for more information.

azbankgateways/banks/banks.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from django.utils import timezone
1111

1212
from .. import default_settings as settings
13+
from django.conf import settings as django_settings
1314
from ..exceptions import (
1415
AmountDoesNotSupport,
1516
BankGatewayStateInvalid,
@@ -42,6 +43,9 @@ def __init__(self, identifier: str, **kwargs):
4243
self.identifier = identifier
4344
self.default_setting_kwargs = kwargs
4445
self.set_default_settings()
46+
47+
def _is_strict_origin_policy_enabled(self):
48+
return django_settings.SECURE_REFERRER_POLICY == 'strict-origin-when-cross-origin'
4549

4650
@abc.abstractmethod
4751
def set_default_settings(self):

azbankgateways/banks/bmi.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ class BMI(BaseBank):
2020
_terminal_code = None
2121
_secret_key = None
2222

23-
def _is_strict_origin_policy_enabled(self):
24-
return settings.SECURE_REFERRER_POLICY == 'strict-origin-when-cross-origin'
25-
2623
def __init__(self, **kwargs):
2724
super(BMI, self).__init__(**kwargs)
2825
if not self._is_strict_origin_policy_enabled():

0 commit comments

Comments
 (0)