Add logout, appearance fixes
All checks were successful
Deploy Service / deploy (push) Successful in 27s
All checks were successful
Deploy Service / deploy (push) Successful in 27s
This commit is contained in:
parent
eae7fceb48
commit
cf4f797420
3 changed files with 36 additions and 3 deletions
|
@ -19,7 +19,7 @@ import urllib.parse
|
|||
from mutagen.id3 import ID3, APIC
|
||||
import logging
|
||||
from cachetools import LRUCache
|
||||
from sqlalchemy import select, update
|
||||
from sqlalchemy import select, update, delete
|
||||
import jwt
|
||||
|
||||
|
||||
|
@ -105,6 +105,20 @@ async def set_default(e: events.CallbackQuery.Event):
|
|||
await e.respond("Default service updated")
|
||||
|
||||
|
||||
@client.on(events.NewMessage(pattern='/logout'))
|
||||
async def confirm_logout(e: events.NewMessage.Event):
|
||||
await e.respond('This action will delete all your data. Continue?', buttons=[Button.inline('Yes', 'confirm_logout')])
|
||||
|
||||
|
||||
@client.on(events.CallbackQuery(pattern='confirm_logout'))
|
||||
async def logout(e: events.CallbackQuery.Event):
|
||||
async with get_session_context() as session:
|
||||
await session.execute(
|
||||
delete(User).where(User.id == e.sender_id)
|
||||
)
|
||||
await e.respond('Logged out successfully. Use /start to continue using the bot')
|
||||
|
||||
|
||||
async def fetch_file(url) -> bytes:
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.get(url) as response:
|
||||
|
|
|
@ -125,7 +125,7 @@ async def spotify_callback(
|
|||
user = User(id=data['tg_id'], spotify_auth=creds, default="spotify")
|
||||
session.add(user)
|
||||
reply = "Account linked!"
|
||||
if user.spotify_auth:
|
||||
if user.ymusic_auth:
|
||||
reply += second_provider_notification
|
||||
await client.send_message(data['tg_id'], reply)
|
||||
return FileResponse("app/static/success.html", media_type="text/html")
|
||||
|
|
|
@ -75,7 +75,14 @@
|
|||
<ol>
|
||||
<li>Visit <a href="https://developer.spotify.com/dashboard" target="_blank">Spotify Developer Dashboard</a></li>
|
||||
<li>Log in and create an app</li>
|
||||
<li>Fill any name and description. Set redirect url to: {{ redirect_url }}</li>
|
||||
<li>Fill any name and description</li>
|
||||
<li>
|
||||
Set redirect url to:
|
||||
<span id="redirectUrl" style="cursor: pointer; color: #2563eb; text-decoration: underline;" onclick="copyRedirectUrl()">
|
||||
{{ redirect_url }}
|
||||
</span>
|
||||
(click to copy)
|
||||
</li>
|
||||
<li>Copy your <strong>Client ID</strong> and <strong>Client Secret</strong></li>
|
||||
</ol>
|
||||
|
||||
|
@ -87,6 +94,12 @@
|
|||
<input type="hidden" id="state" value="{{ state }}">
|
||||
|
||||
<button id="authorizeBtn" onclick="">Authorize</button>
|
||||
|
||||
<div style="position: fixed; bottom: 20px; right: 20px; font-size: 0.85rem;">
|
||||
<a href="/static/privacy.html" target="_blank" style="color: #2563eb; text-decoration: underline;">
|
||||
How we use this data
|
||||
</a>
|
||||
</div>
|
||||
<script>
|
||||
document.getElementById('authorizeBtn').addEventListener('click', async () => {
|
||||
const clientId = document.getElementById('clientId').value;
|
||||
|
@ -117,5 +130,11 @@
|
|||
}
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
function copyRedirectUrl() {
|
||||
const text = document.getElementById('redirectUrl').innerText;
|
||||
navigator.clipboard.writeText(text)
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Add table
Reference in a new issue