Added new pages, and added user approval and login to external services (Still need to add service tokens)
This commit is contained in:
518
templates/approveservice.html
Normal file
518
templates/approveservice.html
Normal file
@@ -0,0 +1,518 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Approve Service | {{ appName }}</title>
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
|
||||
<style>
|
||||
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=Inter:wght@400;500;600&display=swap');
|
||||
|
||||
:root {
|
||||
--brand-primary: #6366f1;
|
||||
--brand-hover: #4f46e5;
|
||||
--brand-success: #10b981;
|
||||
--brand-error: #ef4444;
|
||||
--text-main: #0f172a;
|
||||
--text-muted: #64748b;
|
||||
--bg-body: #f8fafc;
|
||||
--border-color: #e2e8f0;
|
||||
--shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
|
||||
--shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
|
||||
--radius-xl: 2rem;
|
||||
--radius-lg: 0.75rem;
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Inter', sans-serif;
|
||||
background-color: var(--bg-body);
|
||||
background-image:
|
||||
radial-gradient(at 0% 0%, hsla(253,16%,95%,1) 0, transparent 50%),
|
||||
radial-gradient(at 100% 0%, hsla(225,39%,90%,1) 0, transparent 50%);
|
||||
height: 100vh;
|
||||
width: 100vw;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 1rem;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.login-card {
|
||||
max-width: 448px;
|
||||
width: 100%;
|
||||
background: #ffffff;
|
||||
border-radius: var(--radius-xl);
|
||||
box-shadow: var(--shadow-xl);
|
||||
border: 1px solid var(--border-color);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.card-content {
|
||||
padding: 2.5rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.brand-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.brand-icon {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
background: var(--brand-primary);
|
||||
border-radius: 8px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: white;
|
||||
box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.brand-name {
|
||||
font-family: 'Space Grotesk', sans-serif;
|
||||
font-size: 1.25rem;
|
||||
font-weight: 700;
|
||||
color: var(--text-main);
|
||||
letter-spacing: -0.025em;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-family: 'Space Grotesk', sans-serif;
|
||||
font-size: 1.875rem;
|
||||
font-weight: 700;
|
||||
color: var(--text-main);
|
||||
margin-bottom: 0.5rem;
|
||||
letter-spacing: -0.025em;
|
||||
}
|
||||
|
||||
.description {
|
||||
color: var(--text-muted);
|
||||
font-size: 0.875rem;
|
||||
margin-bottom: 2rem;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.input-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: #ffffff;
|
||||
border: 2px solid var(--border-color);
|
||||
border-radius: var(--radius-lg);
|
||||
padding: 0 1rem;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.input-container:focus-within {
|
||||
border-color: var(--brand-primary);
|
||||
box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
|
||||
}
|
||||
|
||||
.input-container i {
|
||||
color: var(--text-muted);
|
||||
margin-right: 0.75rem;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
input {
|
||||
width: 100%;
|
||||
border: none;
|
||||
outline: none;
|
||||
padding: 0.875rem 0;
|
||||
font-size: 1rem;
|
||||
color: var(--text-main);
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.btn {
|
||||
width: 100%;
|
||||
padding: 1rem;
|
||||
border-radius: var(--radius-lg);
|
||||
border: none;
|
||||
font-size: 1rem;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 0.5rem;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: var(--brand-primary);
|
||||
color: white;
|
||||
box-shadow: 0 4px 10px rgba(99, 102, 241, 0.2);
|
||||
}
|
||||
|
||||
.btn-primary:hover:not(:disabled) {
|
||||
background: var(--brand-hover);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.btn-primary:disabled {
|
||||
opacity: 0.7;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.btn-text {
|
||||
background: transparent;
|
||||
color: var(--text-muted);
|
||||
border: none;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 500;
|
||||
margin-top: 1rem;
|
||||
cursor: pointer;
|
||||
transition: color 0.2s;
|
||||
}
|
||||
|
||||
.btn-text:hover {
|
||||
color: var(--brand-primary);
|
||||
}
|
||||
|
||||
.back-link {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
color: var(--text-muted);
|
||||
font-size: 0.75rem;
|
||||
font-weight: 700;
|
||||
text-decoration: none;
|
||||
margin-bottom: 1.5rem;
|
||||
cursor: pointer;
|
||||
transition: color 0.2s;
|
||||
}
|
||||
|
||||
.back-link:hover {
|
||||
color: var(--brand-primary);
|
||||
}
|
||||
|
||||
.identity-chip {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
background: var(--bg-body);
|
||||
border: 1px solid var(--border-color);
|
||||
padding: 0.375rem 0.75rem;
|
||||
border-radius: 0.5rem;
|
||||
font-size: 0.75rem;
|
||||
color: var(--text-muted);
|
||||
width: fit-content;
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.hidden { display: none !important; }
|
||||
|
||||
.error-box {
|
||||
background: #fef2f2;
|
||||
border-left: 4px solid var(--brand-error);
|
||||
color: #b91c1c;
|
||||
padding: 0.75rem;
|
||||
border-radius: 0 0.5rem 0.5rem 0;
|
||||
font-size: 0.75rem;
|
||||
margin-bottom: 1.5rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.success-state {
|
||||
text-align: center;
|
||||
padding: 1rem 0;
|
||||
}
|
||||
|
||||
.success-icon {
|
||||
width: 64px;
|
||||
height: 64px;
|
||||
background: #ecfdf5;
|
||||
color: var(--brand-success);
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 1.5rem;
|
||||
margin: 0 auto 1.5rem;
|
||||
}
|
||||
|
||||
.step-transition {
|
||||
animation: fadeInScale 0.4s cubic-bezier(0.16, 1, 0.3, 1);
|
||||
}
|
||||
|
||||
@keyframes fadeInScale {
|
||||
from { opacity: 0; transform: scale(0.99) translateY(5px); }
|
||||
to { opacity: 1; transform: scale(1) translateY(0); }
|
||||
}
|
||||
|
||||
.loader {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
border: 2px solid rgba(255,255,255,0.3);
|
||||
border-top-color: #fff;
|
||||
border-radius: 50%;
|
||||
animation: spin 0.8s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
.toggle-btn {
|
||||
background: none;
|
||||
border: none;
|
||||
color: var(--text-muted);
|
||||
cursor: pointer;
|
||||
padding: 0.5rem;
|
||||
}
|
||||
|
||||
/* Mobile and popup responsiveness */
|
||||
@media (max-width: 768px) {
|
||||
body {
|
||||
padding: 0;
|
||||
align-items: stretch;
|
||||
justify-content: stretch;
|
||||
}
|
||||
|
||||
.login-card {
|
||||
max-width: none;
|
||||
width: 100%;
|
||||
height: 100vh;
|
||||
border-radius: 0;
|
||||
border: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.card-content {
|
||||
padding: 1.5rem;
|
||||
height: 100%;
|
||||
justify-content: flex-start;
|
||||
padding-top: 2rem;
|
||||
}
|
||||
|
||||
.brand-header {
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
.description {
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="login-card">
|
||||
<div class="card-content">
|
||||
<!-- Brand -->
|
||||
<div class="brand-header">
|
||||
<div class="brand-icon">
|
||||
<i class="fa-solid fa-key"></i>
|
||||
</div>
|
||||
<span class="brand-name">{{ appName }}</span>
|
||||
</div>
|
||||
|
||||
<!-- Stage 1: Service Request -->
|
||||
<div id="stage1" class="step-transition">
|
||||
<h2>Sign In</h2>
|
||||
<p class="description">Do you want to sign into <strong>{{ serviceName }}</strong>?</p>
|
||||
|
||||
<div style="display: flex; flex-direction: column; gap: 1rem; margin-top: 2rem;">
|
||||
<button type="button" class="btn btn-primary" onclick="toStage2()">
|
||||
<i class="fa-solid fa-arrow-right" style="font-size: 0.75rem; opacity: 0.7;"></i>
|
||||
Next
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Stage 2: Permissions -->
|
||||
<div id="stage2" class="step-transition hidden">
|
||||
<div class="back-link" onclick="backToStage1()">
|
||||
<i class="fa-solid fa-chevron-left"></i>
|
||||
Back
|
||||
</div>
|
||||
|
||||
<h2>Permissions</h2>
|
||||
<p class="description">{{ serviceName }} is requesting the following permissions:</p>
|
||||
|
||||
{% for i in permissions: %}
|
||||
<div style="background: var(--bg-body); border-radius: var(--radius-lg); padding: 1rem; margin-bottom: 0.75rem;">
|
||||
<div style="display: flex; align-items: center; gap: 0.75rem;">
|
||||
<i class="fa-solid fa-circle-check" style="color: var(--brand-primary); font-size: 1.25rem;"></i>
|
||||
<div>
|
||||
<div style="font-weight: 600; color: var(--text-main); font-size: 0.875rem;">{{ i[0] }}</div>
|
||||
<div style="color: var(--text-muted); font-size: 0.75rem; margin-top: 0.25rem;">{{ i[1] }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
<div style="display: flex; flex-direction: column; gap: 1rem; margin-top: 1.5rem;">
|
||||
<button type="button" class="btn btn-primary" onclick="toStage3()">
|
||||
<i class="fa-solid fa-arrow-right" style="font-size: 0.75rem; opacity: 0.7;"></i>
|
||||
Next
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Stage 3: Approval -->
|
||||
<div id="stage3" class="step-transition hidden">
|
||||
<div class="back-link" onclick="backToStage2()">
|
||||
<i class="fa-solid fa-chevron-left"></i>
|
||||
Back
|
||||
</div>
|
||||
<div class="success-state">
|
||||
<div class="success-icon">
|
||||
<i class="fa-solid fa-check"></i>
|
||||
</div>
|
||||
<h2>You are logging into</h2>
|
||||
<p style="color: var(--text-muted); font-size: 1.125rem; font-weight: 600; margin-bottom: 1.5rem;">{{ serviceName }}</p>
|
||||
<div style="display: flex; flex-direction: column; gap: 1rem;">
|
||||
<button type="button" class="btn btn-primary" id="approveBtn" onclick="approveService()">
|
||||
<span id="approveLoader" class="loader hidden"></span>
|
||||
<span id="approveText">Approve</span>
|
||||
</button>
|
||||
<button type="button" class="btn" id="denyBtn" style="background: transparent; color: var(--text-muted); border: 2px solid var(--border-color);" onclick="denyService()">
|
||||
<span id="denyLoader" class="loader hidden" style="border-color: rgba(100, 116, 139, 0.3); border-top-color: #64748b;"></span>
|
||||
<i id="denyIcon" class="fa-solid fa-xmark" style="font-size: 0.75rem; opacity: 0.7;"></i>
|
||||
<span id="denyText">Deny</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="stage4" class="step-transition hidden">
|
||||
<div class="success-state">
|
||||
<div class="success-icon" style="background: #fef2f2; color: var(--brand-error);">
|
||||
<i class="fa-solid fa-xmark"></i>
|
||||
</div>
|
||||
<h2>Access Denied</h2>
|
||||
<p class="description">You have denied access to <strong>{{ serviceName }}</strong>.</p>
|
||||
<button type="button" class="btn btn-primary" onclick="closeTab()" style="background: var(--brand-error); margin-top: 1.5rem;">
|
||||
<i class="fa-solid fa-xmark" style="font-size: 0.75rem; opacity: 0.7;"></i>
|
||||
Close Tab
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Check if in popup and apply fullscreen styling
|
||||
if (window.opener || window.self !== window.top) {
|
||||
document.documentElement.style.width = '100vw';
|
||||
document.documentElement.style.height = '100vh';
|
||||
document.body.style.width = '100vw';
|
||||
document.body.style.height = '100vh';
|
||||
document.querySelector('.login-card').style.maxWidth = 'none';
|
||||
document.querySelector('.login-card').style.width = '100%';
|
||||
document.querySelector('.login-card').style.height = '100vh';
|
||||
document.querySelector('.login-card').style.borderRadius = '0';
|
||||
document.querySelector('.login-card').style.border = 'none';
|
||||
document.querySelector('.login-card').style.boxShadow = 'none';
|
||||
}
|
||||
|
||||
const stages = {
|
||||
1: document.getElementById('stage1'),
|
||||
2: document.getElementById('stage2'),
|
||||
3: document.getElementById('stage3'),
|
||||
4: document.getElementById('stage4')
|
||||
};
|
||||
|
||||
function switchStage(to) {
|
||||
Object.values(stages).forEach(s => s.classList.add('hidden'));
|
||||
stages[to].classList.remove('hidden');
|
||||
}
|
||||
|
||||
function toStage2() {
|
||||
switchStage(2);
|
||||
}
|
||||
|
||||
function toStage3() {
|
||||
switchStage(3);
|
||||
}
|
||||
|
||||
function backToStage1() {
|
||||
switchStage(1);
|
||||
}
|
||||
|
||||
function backToStage2() {
|
||||
switchStage(2);
|
||||
}
|
||||
|
||||
async function approveService() {
|
||||
const btn = document.getElementById('approveBtn');
|
||||
const loader = document.getElementById('approveLoader');
|
||||
const text = document.getElementById('approveText');
|
||||
|
||||
btn.disabled = true;
|
||||
loader.classList.remove('hidden');
|
||||
text.innerText = 'Completing...';
|
||||
|
||||
try {
|
||||
const response = await fetch("{{ url_for('logIntoService') }}", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
"request_id": "{{ requestToken }}",
|
||||
"service_id": "{{ serviceId }}",
|
||||
"redirect_url": "{{ redirectUrl }}"
|
||||
}),
|
||||
});
|
||||
if (!response.ok) {
|
||||
return { success: false, message: "Signup failed" };
|
||||
}
|
||||
const result = await response.json();
|
||||
return { success: true, result };
|
||||
} catch (error) {
|
||||
console.error(error.message);
|
||||
return { success: false, message: error.message };
|
||||
}
|
||||
}
|
||||
|
||||
function denyService() {
|
||||
const btn = document.getElementById('denyBtn');
|
||||
const loader = document.getElementById('denyLoader');
|
||||
const icon = document.getElementById('denyIcon');
|
||||
const text = document.getElementById('denyText');
|
||||
|
||||
btn.disabled = true;
|
||||
loader.classList.remove('hidden');
|
||||
icon.classList.add('hidden');
|
||||
text.innerText = 'Denying...';
|
||||
|
||||
setTimeout(() => {
|
||||
switchStage(4);
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
function closeTab() {
|
||||
if (window.opener) {
|
||||
window.close();
|
||||
} else {
|
||||
window.location.href = '/';
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user