Skip to content

Commit

Permalink
logout fix
Browse files Browse the repository at this point in the history
Signed-off-by: viste <[email protected]>
  • Loading branch information
Viste committed Aug 20, 2024
1 parent 8f43031 commit 27bfea5
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions core/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ def authorize_vk():
if 'access_token' not in tokens or 'device_id' not in tokens:
flash('Failed to retrieve access token or device ID', 'danger')
current_app.logger.debug(f"Failed to retrieve tokens from VK. Response: {tokens}")
logout_vk()
session.clear()
return redirect(url_for('login'))

Expand Down Expand Up @@ -248,17 +249,15 @@ def refresh_vk_token(refresh_token):

def logout_vk():
access_token = session.get('access_token')
device_id = session.get('device_id')

if not access_token or not device_id:
flash('Failed to logout: Missing access token or device ID.', 'danger')
current_app.logger.debug(f"Failed to logout from VK. Missing access token or device ID.")
return redirect(url_for('index'))
if not access_token:
flash('Failed to logout: Missing access token.', 'danger')
current_app.logger.debug(f"Failed to logout from VK. Missing access token.")
return

data = {
'client_id': Config.VK_CLIENT_ID,
'access_token': access_token,
'device_id': device_id
'access_token': access_token
}

current_app.logger.debug(f"Logging out from VK. Data: {data}")
Expand All @@ -275,8 +274,6 @@ def logout_vk():
session.pop('access_token', None)
session.pop('device_id', None)

return response.json()

@app.route('/logout')
@login_required
def logout():
Expand Down

0 comments on commit 27bfea5

Please sign in to comment.