Hotfix(sub): Display correct user data on blocked page
This commit is contained in:
@ -124,6 +124,7 @@ class TemplateContext:
|
||||
expiration_date: str
|
||||
sublink_qrcode: str
|
||||
sub_link: str
|
||||
blocked: bool = False
|
||||
local_uris: List[NodeURI] = field(default_factory=list)
|
||||
node_uris: List[NodeURI] = field(default_factory=list)
|
||||
|
||||
@ -558,7 +559,7 @@ class HysteriaServer:
|
||||
return web.Response(status=404, text=f"User '{username}' details not found.")
|
||||
|
||||
if user_info.blocked:
|
||||
return await self._handle_blocked_user(request)
|
||||
return await self._handle_blocked_user(request, user_info)
|
||||
|
||||
user_agent = request.headers.get('User-Agent', '').lower()
|
||||
if any(browser in user_agent for browser in ['chrome', 'firefox', 'safari', 'edge', 'opera']):
|
||||
@ -573,12 +574,12 @@ class HysteriaServer:
|
||||
print(f"Internal Server Error: {e}")
|
||||
return web.Response(status=500, text="Error: Internal server error")
|
||||
|
||||
async def _handle_blocked_user(self, request: web.Request) -> web.Response:
|
||||
async def _handle_blocked_user(self, request: web.Request, user_info: UserInfo) -> web.Response:
|
||||
fake_uri = "hysteria2://x@end.com:443?sni=support.me#⛔Account-Expired⚠️"
|
||||
user_agent = request.headers.get('User-Agent', '').lower()
|
||||
|
||||
if any(browser in user_agent for browser in ['chrome', 'firefox', 'safari', 'edge', 'opera']):
|
||||
context = self._get_blocked_template_context(fake_uri)
|
||||
context = self._get_blocked_template_context(fake_uri, user_info)
|
||||
return web.Response(text=self.template_renderer.render(context), content_type='text/html')
|
||||
|
||||
fragment = request.query.get('fragment', '')
|
||||
@ -588,19 +589,20 @@ class HysteriaServer:
|
||||
|
||||
return web.Response(text=fake_uri, content_type='text/plain')
|
||||
|
||||
def _get_blocked_template_context(self, fake_uri: str) -> TemplateContext:
|
||||
def _get_blocked_template_context(self, fake_uri: str, user_info: UserInfo) -> TemplateContext:
|
||||
return TemplateContext(
|
||||
username="blocked",
|
||||
usage="N/A",
|
||||
username=user_info.username,
|
||||
usage=user_info.usage_human_readable,
|
||||
usage_raw="This account has been suspended.",
|
||||
expiration_date="N/A",
|
||||
sublink_qrcode=Utils.generate_qrcode_base64("blocked"),
|
||||
expiration_date=user_info.expiration_date,
|
||||
sublink_qrcode="",
|
||||
sub_link="#blocked",
|
||||
blocked=True,
|
||||
local_uris=[
|
||||
NodeURI(
|
||||
label="Blocked",
|
||||
uri=fake_uri,
|
||||
qrcode=Utils.generate_qrcode_base64(fake_uri)
|
||||
qrcode=None
|
||||
)
|
||||
],
|
||||
node_uris=[]
|
||||
@ -656,6 +658,7 @@ class HysteriaServer:
|
||||
expiration_date=user_info.expiration_date,
|
||||
sublink_qrcode=sublink_qrcode,
|
||||
sub_link=sub_link,
|
||||
blocked=user_info.blocked,
|
||||
local_uris=local_uris,
|
||||
node_uris=node_uris
|
||||
)
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
:root {
|
||||
--primary-gradient: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
|
||||
--secondary-gradient: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
|
||||
--danger-color: #ef4444;
|
||||
--card-bg-light: #ffffff;
|
||||
--card-bg-dark: #1f2937;
|
||||
--text-light: #1f2937;
|
||||
@ -187,6 +188,10 @@
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.qr-header.blocked {
|
||||
background: var(--danger-color);
|
||||
}
|
||||
|
||||
.qr-content {
|
||||
padding: 2rem;
|
||||
@ -213,9 +218,17 @@
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.qr-title.blocked {
|
||||
color: var(--danger-color);
|
||||
}
|
||||
|
||||
.dark-mode .qr-title {
|
||||
color: #818cf8;
|
||||
}
|
||||
|
||||
.dark-mode .qr-title.blocked {
|
||||
color: #f87171;
|
||||
}
|
||||
|
||||
.qrcode {
|
||||
max-width: 200px;
|
||||
@ -361,12 +374,18 @@
|
||||
</div>
|
||||
|
||||
<div class="qr-section">
|
||||
<div class="qr-header">
|
||||
<div class="qr-header {% if blocked %}blocked{% endif %}">
|
||||
<i class="fas fa-link"></i>
|
||||
Subscription Link
|
||||
</div>
|
||||
<div class="qr-content">
|
||||
<div class="qr-grid">
|
||||
{% if blocked %}
|
||||
<div class="qr-item" style="grid-column: 1 / -1;">
|
||||
<h3 class="qr-title blocked">Account Suspended</h3>
|
||||
<p class="card-text">Your subscription link is disabled. Please contact support.</p>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="qr-item" style="grid-column: 1 / -1;">
|
||||
<h3 class="qr-title">Universal Subscription Link</h3>
|
||||
<img src="{{ sublink_qrcode }}" alt="Subscription QR Code" class="qrcode">
|
||||
@ -376,37 +395,51 @@
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="qr-section">
|
||||
<div class="qr-header">
|
||||
<div class="qr-header {% if blocked %}blocked{% endif %}">
|
||||
<i class="fas fa-server"></i>
|
||||
Local Server Connections
|
||||
{% if blocked %}
|
||||
Connection Status
|
||||
{% else %}
|
||||
Local Server Connections
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="qr-content">
|
||||
<div class="qr-grid">
|
||||
{% for item in local_uris %}
|
||||
<div class="qr-item">
|
||||
<h3 class="qr-title">{{ item.label }} URI</h3>
|
||||
{% if item.qrcode %}
|
||||
<img src="{{ item.qrcode }}" alt="{{ item.label }} QR Code" class="qrcode">
|
||||
<div class="btn-group">
|
||||
<button class="btn btn-primary" onclick="copyToClipboard('{{ item.uri }}')">
|
||||
<i class="fas fa-copy"></i> Copy
|
||||
</button>
|
||||
{% if blocked %}
|
||||
{% for item in local_uris %}
|
||||
<div class="qr-item" style="grid-column: 1 / -1;">
|
||||
<h3 class="qr-title blocked">{{ item.label }}</h3>
|
||||
<p class="card-text">{{ usage_raw }}</p>
|
||||
</div>
|
||||
{% else %}
|
||||
<p class="uri-unavailable">{{ item.label }} URI not available</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
{% for item in local_uris %}
|
||||
<div class="qr-item">
|
||||
<h3 class="qr-title">{{ item.label }} URI</h3>
|
||||
{% if item.qrcode %}
|
||||
<img src="{{ item.qrcode }}" alt="{{ item.label }} QR Code" class="qrcode">
|
||||
<div class="btn-group">
|
||||
<button class="btn btn-primary" onclick="copyToClipboard('{{ item.uri }}')">
|
||||
<i class="fas fa-copy"></i> Copy
|
||||
</button>
|
||||
</div>
|
||||
{% else %}
|
||||
<p class="uri-unavailable">{{ item.label }} URI not available</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if node_uris %}
|
||||
{% if node_uris and not blocked %}
|
||||
<div class="qr-section">
|
||||
<div class="qr-header">
|
||||
<i class="fas fa-globe-americas"></i>
|
||||
|
||||
Reference in New Issue
Block a user