Skip to content

Commit cb0de0a

Browse files
committed
[SDK-165]: Removed login button helper functions from Example projects, as these are now defunct.
1 parent 8a10d67 commit cb0de0a

File tree

17 files changed

+36
-161
lines changed

17 files changed

+36
-161
lines changed

examples/yoti_example_django/yoti_example/templates/index.html

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,13 @@
1111
<!-- Your website content -->
1212

1313
<!-- This span will create the Yoti button -->
14-
<span
15-
data-yoti-application-id="{{ app_id }}"
16-
data-size="small"
17-
>
14+
<span data-yoti-application-id="{{app_id}}">
1815
Log in with Yoti
1916
</span>
2017

21-
<!-- This script snippet will also be required in your HTML body during the early pilot period -->
18+
<!-- This script snippet will also be required in your HTML body -->
2219
<script>
23-
_ybg.config.service = 'https://www.yoti.com/connect/';
24-
_ybg.init();
20+
_ybg.init()
2521
</script>
2622
</body>
2723
</html>

examples/yoti_example_django/yoti_example/views.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
from binascii import a2b_base64
2+
from os.path import join, dirname
23

34
from django.views.generic import TemplateView
4-
5-
from os.path import join, dirname
65
from dotenv import load_dotenv
76

87
dotenv_path = join(dirname(__file__), '.env')

examples/yoti_example_flask/templates/index.html

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,13 @@
1111
<!-- Your website content -->
1212

1313
<!-- This span will create the Yoti button -->
14-
<span
15-
data-yoti-application-id="{{ app_id }}"
16-
data-size="small"
17-
>
14+
<span data-yoti-application-id="{{app_id}}">
1815
Log in with Yoti
1916
</span>
2017

21-
<!-- This script snippet will also be required in your HTML body during the early pilot period -->
18+
<!-- This script snippet will also be required in your HTML body -->
2219
<script>
23-
_ybg.config.service = 'https://www.yoti.com/connect/';
24-
_ybg.init();
20+
_ybg.init()
2521
</script>
2622
</body>
2723
</html>

plugins/django_yoti/README.md

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,12 @@ INSTALLED_APPS = [
1717
]
1818
```
1919

20-
* Django Yoti plugin provides the following template context vars:
20+
* Django Yoti plugin provides the following template context var:
2121
- `yoti_application_id`
22-
- `yoti_login_button_*`
2322

2423
* If you're using a Django template backend that supports context processors
2524
like default DTL (Django Template Language) and want to use context tags
26-
inside your template (e.g. `{{ yoti_login_button_*}}`), then you should
25+
inside your template (e.g. `{{yoti_application_id}}`), then you should
2726
include `django_yoti`'s context processors into your templates
2827
configuration like this:
2928
```python
@@ -106,7 +105,6 @@ YOTI = {
106105
...
107106
'YOTI_LOGIN_VIEW': '...',
108107
'YOTI_REDIRECT_TO': '...',
109-
'YOTI_LOGIN_BUTTON_LABEL': '...',
110108
}
111109
```
112110
* **`YOTI_LOGIN_VIEW`**<br>
@@ -159,13 +157,12 @@ Your Yoti application's callback URL should point to `your_site.com/yoti/auth`.
159157
## Using plugin ##
160158

161159
1. First you need to add a login button to some of your view's templates.
162-
- You can do it by using one of the predefined login buttons:
160+
- You can do it by using the predefined login button:
161+
```HTML
162+
<span data-yoti-application-id="{{app_id}}">
163+
Log in with Yoti
164+
</span>
163165
```
164-
{{ yoti_login_button_sm }}
165-
{{ yoti_login_button_md }}
166-
{{ yoti_login_button_lg }}
167-
```
168-
- or with a default one `{{ yoti_login_button }}`<br>
169166

170167
By clicking this button, user will be redirected to the Yoti Authentication page.
171168

plugins/django_yoti/django_yoti/context_processors.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,8 @@
1-
from .login_button import get_login_button_html
21
from .settings import YOTI_APPLICATION_ID
32

43

54
def yoti_context(request=None):
6-
context = login_button_context()
7-
context.update(application_context())
8-
return context
9-
10-
11-
def login_button_context():
12-
return {
13-
'yoti_login_button': get_login_button_html,
14-
'yoti_login_button_sm': get_login_button_html('small'),
15-
'yoti_login_button_md': get_login_button_html('medium'),
16-
'yoti_login_button_lg': get_login_button_html('large')
17-
}
5+
return application_context()
186

197

208
def application_context():

plugins/django_yoti/django_yoti/login_button.py

Lines changed: 0 additions & 14 deletions
This file was deleted.

plugins/django_yoti/django_yoti/settings.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,11 @@ def _get_parameter(name, required=True):
2020

2121
YOTI_REDIRECT_TO = GLOBAL_YOTI_SETTINGS.get('YOTI_REDIRECT_TO', 'yoti_profile')
2222
YOTI_LOGIN_VIEW = GLOBAL_YOTI_SETTINGS.get('YOTI_LOGIN_VIEW', 'yoti_login')
23-
YOTI_LOGIN_BUTTON_LABEL = GLOBAL_YOTI_SETTINGS.get('YOTI_LOGIN_BUTTON_LABEL',
24-
'Log in with Yoti')
2523

2624
__all__ = [
2725
'YOTI_APPLICATION_ID',
2826
'YOTI_CLIENT_SDK_ID',
2927
'YOTI_KEY_FILE_PATH',
3028
'YOTI_REDIRECT_TO',
3129
'YOTI_LOGIN_VIEW',
32-
'YOTI_LOGIN_BUTTON_LABEL',
3330
]

plugins/django_yoti/django_yoti/templates/login_button.html

Lines changed: 0 additions & 1 deletion
This file was deleted.

plugins/django_yoti/django_yoti/templates/yoti_login.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@
1111
<!-- Your website content -->
1212

1313
<!-- This span will create the Yoti button -->
14-
<div>Button: {{ yoti_login_button }}</div>
14+
<span data-yoti-application-id="{{app_id}}">
15+
Log in with Yoti
16+
</span>
1517

16-
<!-- This script snippet will also be required in your HTML body during the early pilot period -->
18+
<!-- This script snippet will also be required in your HTML body -->
1719
<script>
18-
_ybg.config.service = 'https://www.yoti.com/connect/';
19-
_ybg.init();
20+
_ybg.init()
2021
</script>
2122
</body>
2223
</html>
Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from django.test import TestCase
22

33
from ..context_processors import yoti_context
4-
from ..login_button import get_login_button_html
54

65

76
class TestContextProcessors(TestCase):
@@ -11,37 +10,13 @@ def setUp(self):
1110
'YOTI_APPLICATION_ID': '01234567-8901-2345-6789-012345678901',
1211
'YOTI_CLIENT_SDK_ID': '01234567-8901-2345-6789-012345678901',
1312
'YOTI_KEY_FILE_PATH': '/home/user/.ssh/yoti_key.pem',
14-
'YOTI_LOGIN_BUTTON_LABEL': 'Test label'
1513
}
1614

1715
def test_yoti_context(self):
18-
keys = ('yoti_application_id',
19-
'yoti_login_button', 'yoti_login_button_sm',
20-
'yoti_login_button_md', 'yoti_login_button_lg')
21-
self.assertEqual(set(self.context.keys()), set(keys))
16+
application_id_key = 'yoti_application_id'
17+
self.assert_(application_id_key in self.context.keys())
2218

2319
def test_application_id(self):
2420
app_id = self.context.get('yoti_application_id')
2521
expected_app_id = self.defaults.get('YOTI_APPLICATION_ID')
2622
self.assertEqual(app_id, expected_app_id)
27-
28-
def test_predefined_login_buttons(self):
29-
context = self.context
30-
self.assertIn('data-size="small"', context.get('yoti_login_button_sm'))
31-
self.assertIn('data-size="medium"', context.get('yoti_login_button_md'))
32-
self.assertIn('data-size="large"', context.get('yoti_login_button_lg'))
33-
34-
def test_login_button_func(self):
35-
app_id = self.defaults.get('YOTI_APPLICATION_ID')
36-
button_label = self.defaults.get('YOTI_LOGIN_BUTTON_LABEL')
37-
login_button_func = self.context.get('yoti_login_button')
38-
self.assertTrue(hasattr(login_button_func, '__call__'))
39-
button_html = login_button_func(text=button_label)
40-
expected = '<span data-yoti-application-id="{0}" >' \
41-
'{1}</span>'.format(app_id, button_label)
42-
self.assertEqual(button_html, expected)
43-
44-
def test_context_login_button_func_with_different_sizes(self):
45-
for size in ('small', 'medium', 'large'):
46-
button_html = get_login_button_html(size)
47-
self.assertIn('data-size="{0}"'.format(size), button_html)

0 commit comments

Comments
 (0)