From 71ee91340f54c31369a2896cf0beed9bf5c8d025 Mon Sep 17 00:00:00 2001 From: Administrator Date: Tue, 10 Oct 2023 00:10:08 +0300 Subject: [PATCH] fix everything --- web/views/yandex_auth.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/web/views/yandex_auth.py b/web/views/yandex_auth.py index d0623f2..c8f61a7 100644 --- a/web/views/yandex_auth.py +++ b/web/views/yandex_auth.py @@ -7,7 +7,6 @@ from web.models import CustomUser class YandexAuthView(BaseView): - required_login = False endpoint = "yandex_auth" def get(self): @@ -19,26 +18,26 @@ class YandexAuthView(BaseView): 'code': code }) if response.status_code != 200: - raise Exception("Cant access, json: " + str(response.json())) + print("Cant access, json: " + str(response.json())) return '/welcome' access_token = response.json().get('access_token') if access_token is None: - raise Exception('no access token') + print('no access token') return '/welcome' info_response = get('https://login.yandex.ru/info', headers={ 'Authorization': f'OAuth {access_token}' }) if info_response.status_code != 200: - raise Exception("Cant access, json: " + str(response.json())) + print("Cant access, json: " + str(response.json())) return '/welcome' data = info_response.json() yandex_id = data['id'] if self.request.user.is_authenticated: - raise Exception('Got yandex_id %s writing to db' + str(yandex_id) + " " + type(yandex_id)) + print('Got yandex_id %s writing to db' + str(yandex_id) + " " + type(yandex_id)) self.request.user.yandex_id = yandex_id self.request.user.save() else: - raise Exception('Got yandex_id %s logging in' + str(yandex_id) + " " + type(yandex_id)) + print('Got yandex_id %s logging in' + str(yandex_id) + " " + type(yandex_id)) user = CustomUser.objects.filter(yandex_id=yandex_id).first() if user is not None: login(self.request, user)