Skip to content

Commit 67385dc

Browse files
authored
Update login.html
1 parent b560d43 commit 67385dc

File tree

1 file changed

+183
-30
lines changed

1 file changed

+183
-30
lines changed

login.html

Lines changed: 183 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,67 @@
141141
border-radius: 8px;
142142
margin: 10px 0;
143143
}
144+
145+
/* Modal SSO */
146+
.sso-modal {
147+
position: fixed;
148+
top: 0;
149+
left: 0;
150+
width: 100%;
151+
height: 100%;
152+
background: rgba(0,0,0,0.8);
153+
display: none;
154+
justify-content: center;
155+
align-items: center;
156+
z-index: 1000;
157+
}
158+
159+
.sso-modal-content {
160+
background: #111;
161+
border: 1px solid rgba(212,175,55,0.3);
162+
border-radius: 15px;
163+
padding: 25px;
164+
max-width: 400px;
165+
width: 90%;
166+
}
167+
168+
.sso-input {
169+
width: 100%;
170+
padding: 12px;
171+
margin: 15px 0;
172+
border: 1px solid rgba(212,175,55,0.5);
173+
border-radius: 8px;
174+
background: #1a1a1a;
175+
color: white;
176+
text-align: center;
177+
font-size: 16px;
178+
}
179+
180+
.sso-buttons {
181+
display: flex;
182+
gap: 10px;
183+
margin-top: 15px;
184+
}
185+
186+
.sso-btn {
187+
flex: 1;
188+
padding: 12px;
189+
border-radius: 8px;
190+
cursor: pointer;
191+
font-size: 14px;
192+
}
193+
194+
.sso-btn-cancel {
195+
border: 1px solid #666;
196+
background: #333;
197+
color: #aaa;
198+
}
199+
200+
.sso-btn-continue {
201+
border: 1px solid rgba(212,175,55,0.5);
202+
background: rgba(212,175,55,0.2);
203+
color: #d4af37;
204+
}
144205
</style>
145206
</head>
146207
<body>
@@ -197,7 +258,7 @@ <h3>GitHub Enterprise</h3>
197258
<div class="option-arrow"></div>
198259
</div>
199260

200-
<div class="login-option" onclick="loginSSO()">
261+
<div class="login-option" onclick="openSSOModal()">
201262
<div class="option-icon">🏛️</div>
202263
<div class="option-text">
203264
<h3>SSO Corporativo</h3>
@@ -216,29 +277,119 @@ <h3>SSO Corporativo</h3>
216277
</div>
217278
</div>
218279

280+
<!-- Modal SSO -->
281+
<div class="sso-modal" id="ssoModal">
282+
<div class="sso-modal-content">
283+
<h3 style="color: #d4af37; margin-bottom: 15px; text-align: center;">🏛️ SSO Corporativo</h3>
284+
<p style="color: #aaa; margin-bottom: 10px; text-align: center;">
285+
Digite o domínio da sua empresa para iniciar o login único
286+
</p>
287+
<p style="color: #888; font-size: 12px; margin-bottom: 15px; text-align: center;">
288+
Exemplo: empresa.com
289+
</p>
290+
<input
291+
type="text"
292+
id="ssoDomain"
293+
placeholder="empresa.com"
294+
class="sso-input"
295+
>
296+
<div class="sso-buttons">
297+
<button class="sso-btn sso-btn-cancel" onclick="closeSSOModal()">Cancelar</button>
298+
<button class="sso-btn sso-btn-continue" onclick="proceedSSO()">Continuar</button>
299+
</div>
300+
</div>
301+
</div>
302+
219303
<script>
220-
// FUNÇÃO GITHUB SIMPLES E FUNCIONAL
304+
// FUNÇÃO GITHUB REAL - OAuth
221305
function loginGithub() {
222306
showLoading('GitHub');
223307

224-
// Simula o processo de login
308+
setTimeout(() => {
309+
const clientId = "Ov23liJ8ewJBXHhryv7y";
310+
const redirectUri = "https://armanfm.github.io/Terra-Dourada/auth/github/callback.html";
311+
const scope = "read:user user:email";
312+
313+
const authUrl =
314+
`https://github.com/login/oauth/authorize?client_id=${clientId}` +
315+
`&redirect_uri=${encodeURIComponent(redirectUri)}` +
316+
`&scope=${scope}`;
317+
318+
console.log('🌐 Redirecionando para GitHub OAuth...');
319+
window.location.href = authUrl;
320+
}, 1500);
321+
}
322+
323+
// FUNÇÕES SSO CORPORATIVO
324+
function openSSOModal() {
325+
const modal = document.getElementById('ssoModal');
326+
modal.style.display = 'flex';
327+
328+
// Foca no input após um breve delay
329+
setTimeout(() => {
330+
const input = document.getElementById('ssoDomain');
331+
if (input) {
332+
input.value = '';
333+
input.focus();
334+
}
335+
}, 100);
336+
337+
// Enter para submeter
338+
document.getElementById('ssoDomain').addEventListener('keypress', function(e) {
339+
if (e.key === 'Enter') {
340+
proceedSSO();
341+
}
342+
});
343+
}
344+
345+
function closeSSOModal() {
346+
const modal = document.getElementById('ssoModal');
347+
modal.style.display = 'none';
348+
}
349+
350+
function proceedSSO() {
351+
const dominio = document.getElementById('ssoDomain').value.trim();
352+
353+
if (!dominio) {
354+
alert('Por favor, digite o domínio da sua empresa.');
355+
return;
356+
}
357+
358+
// Validação básica do domínio
359+
if (!dominio.includes('.') || dominio.length < 3) {
360+
alert('Por favor, digite um domínio válido (exemplo: empresa.com)');
361+
return;
362+
}
363+
364+
closeSSOModal();
365+
showLoading('SSO Corporativo');
366+
367+
// AGORA SÓ PROCESSARÁ QUANDO O USUÁRIO CLICAR EM "CONTINUAR"
368+
console.log(`🔐 Iniciando SSO para: ${dominio}`);
369+
370+
// Simulação do fluxo SSO (sem redirecionamento automático)
225371
setTimeout(() => {
226372
const userData = {
227-
provider: "github",
228-
username: "dev-enterprise",
229-
230-
name: "GitHub Enterprise User",
231-
company: "Terra Dourada Corp"
373+
provider: "sso",
374+
dominio: dominio,
375+
email: `usuario@${dominio}`,
376+
name: `Usuário ${dominio}`,
377+
company: dominio.split('.')[0],
378+
sso_type: "OAuth2/SAML",
379+
status: "autenticado"
232380
};
233381

234-
// Salva no localStorage
235382
localStorage.setItem("usuario_logado", "true");
236-
localStorage.setItem("usuario_provider", "github");
383+
localStorage.setItem("usuario_provider", "sso");
237384
localStorage.setItem("usuario_data", JSON.stringify(userData));
238385
localStorage.setItem("usuario_login_time", new Date().toISOString());
239386

240-
console.log('✅ Login GitHub realizado!', userData);
241-
redirectToDashboard();
387+
console.log('✅ Login SSO realizado com sucesso!', userData);
388+
389+
// Redireciona para o dashboard
390+
setTimeout(() => {
391+
window.location.href = "autoridade.html";
392+
}, 1500);
242393
}, 2000);
243394
}
244395

@@ -260,36 +411,32 @@ <h3>SSO Corporativo</h3>
260411
localStorage.setItem("usuario_login_time", new Date().toISOString());
261412

262413
console.log('✅ Login Google realizado!');
263-
redirectToDashboard();
414+
415+
setTimeout(() => {
416+
window.location.href = "autoridade.html";
417+
}, 1000);
264418
}
265419
}
266420

267-
// FUNÇÕES PARA OS OUTROS (simuladas)
421+
// FUNÇÃO MICROSOFT (simulada)
268422
function loginMicrosoft() {
269423
showLoading('Microsoft 365');
270424
setTimeout(() => {
271-
alert('🔷 Microsoft 365 - Em desenvolvimento\n\nPara teste, use Google ou GitHub');
272-
}, 1000);
273-
}
274-
275-
function loginSSO() {
276-
showLoading('SSO Corporativo');
277-
setTimeout(() => {
278-
alert('🏛️ SSO Corporativo - Em desenvolvimento\n\nPara teste, use Google ou GitHub');
425+
alert('🔷 Microsoft 365 - Em desenvolvimento\n\nPara teste, use Google, GitHub ou SSO Corporativo');
426+
hideLoading();
279427
}, 1000);
280428
}
281429

282430
// FUNÇÕES AUXILIARES
283431
function showLoading(provider) {
284432
const loading = document.getElementById('loading');
285-
loading.textContent = `🔄 Conectando com ${provider}...`;
433+
loading.textContent = `🔄 Iniciando conexão com ${provider}...`;
286434
loading.style.display = 'block';
287435
}
288436

289-
function redirectToDashboard() {
290-
setTimeout(() => {
291-
window.location.href = "autoridade.html";
292-
}, 1000);
437+
function hideLoading() {
438+
const loading = document.getElementById('loading');
439+
loading.style.display = 'none';
293440
}
294441

295442
// VERIFICA SE JÁ ESTÁ LOGADO
@@ -322,7 +469,13 @@ <h3>SSO Corporativo</h3>
322469
console.log('🚀 Login Terra Dourada carregado');
323470
checkExistingLogin();
324471

325-
// Debug no console
472+
// Fecha modal se clicar fora
473+
document.getElementById('ssoModal').addEventListener('click', function(e) {
474+
if (e.target === this) {
475+
closeSSOModal();
476+
}
477+
});
478+
326479
console.log('💡 Dica: Digite testLogin() no console para teste rápido');
327480
});
328481

@@ -341,8 +494,8 @@ <h3>SSO Corporativo</h3>
341494
localStorage.setItem("usuario_login_time", new Date().toISOString());
342495

343496
console.log('✅ Login teste realizado!');
344-
redirectToDashboard();
345-
}, 500);
497+
window.location.href = "autoridade.html";
498+
}, 1000);
346499
}
347500
</script>
348501
</body>

0 commit comments

Comments
 (0)