This commit is contained in:
Egor Matveev 2022-04-02 19:22:25 +03:00
parent 80bb8a3dbd
commit f5d6e953a5
3 changed files with 16 additions and 14 deletions

View File

@ -22,7 +22,7 @@ class VKAddView(BaseView):
resp = get(f'https://api.vk.com/method/secure.checkToken?token={access_token}&access_token={token}&v=5.131').json()
print("Got response while adding user", resp)
if 'response' in resp and 'success' in resp['response'] and resp['response']['success'] == 1:
user_id = resp['user_id']
user_id = resp['response']['user_id']
self.request.user.userinfo.vk_user_id = user_id
self.request.user.userinfo.save()
return '/account'

View File

@ -21,7 +21,7 @@ class VKAuthView(BaseView):
token = os.getenv("VK_SERVICE_TOKEN")
resp = get(f'https://api.vk.com/method/secure.checkToken?token={access_token}&access_token={token}&v=5.131').json()
if 'response' in resp and 'success' in resp['response'] and resp['response']['success'] == 1:
user_id = resp['user_id']
user_id = resp['response']['user_id']
try:
user = User.objects.get(userinfo__vk_user_id=user_id)
except ObjectDoesNotExist:

View File

@ -85,17 +85,6 @@
<p style="padding-top: 8px; font-size: 24px;">{{ account.date_joined.date }}</p>
</td>
</tr>
{% if account == user %}
<tr>
<td>
<h2><i class="fa fa-users"></i></h2>
</td>
<td><div style="width: 20px;"></div></td>
<td>
<a href="https://oauth.vk.com/authorize?client_id=8123759&redirect_uri=http://demo.dev.sprinthub.ru/vk_add&display=page&response_type=token&v=5.59"><img style="width: 40px; height: 40px;" src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/f3/VK_Compact_Logo_%282021-present%29.svg/1200px-VK_Compact_Logo_%282021-present%29.svg.png"></a>
</td>
</tr>
{% endif %}
<tr>
<td>
<h2><i class="fa fa-desktop"></i></h2>
@ -122,7 +111,20 @@
{% endif %}
</p></td>
</tr>
{% if owner %}
<tr>
<td>
<h2><i class="fa fa-users"></i></h2>
</td>
<td><div style="width: 20px;"></div></td>
<td>
<a href="https://oauth.vk.com/authorize?client_id=8123759&redirect_uri=http://demo.dev.sprinthub.ru/vk_add&display=page&response_type=token&v=5.59"><img style="width: 40px; height: 40px;" src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/f3/VK_Compact_Logo_%282021-present%29.svg/1200px-VK_Compact_Logo_%282021-present%29.svg.png"></a>
{% if user.userinfo.vk_user_id %}
<div style="margin-top: -15px; margin-left: 30px;"><i style="color: green;" class="fa fa-check-circle"></i></div>
{% endif %}
</td>
</tr>
{% endif %}
</table>
</div>
</div>