fix: keep superadmin access private
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { X, Loader2, GraduationCap, School, ShieldCheck, UserPlus } from 'lucide-react';
|
import { X, Loader2, GraduationCap, School, UserPlus } from 'lucide-react';
|
||||||
import { useAuth } from '../context/AuthContext';
|
import { useAuth } from '../context/AuthContext';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { UserRole } from '../types';
|
import { UserRole } from '../types';
|
||||||
@@ -27,9 +27,9 @@ export const LoginModal: React.FC<LoginModalProps> = ({ isOpen, onClose }) => {
|
|||||||
setError('');
|
setError('');
|
||||||
setIsSubmitting(true);
|
setIsSubmitting(true);
|
||||||
|
|
||||||
if (isRegistering && role !== 'student') {
|
if (isRegistering && role === 'professor') {
|
||||||
setIsSubmitting(false);
|
setIsSubmitting(false);
|
||||||
setError('Contas de instrutor e administrador são liberadas pelo superadmin da plataforma.');
|
setError('Contas de instrutor são liberadas pelo administrador da plataforma.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,13 +45,11 @@ export const LoginModal: React.FC<LoginModalProps> = ({ isOpen, onClose }) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (signedInUser.role !== role) {
|
if (signedInUser.role !== 'superadmin' && signedInUser.role !== role) {
|
||||||
logout();
|
logout();
|
||||||
setError(role === 'superadmin'
|
setError(role === 'professor'
|
||||||
? 'Esta conta não possui acesso de administrador.'
|
? 'Esta conta não possui acesso de instrutor.'
|
||||||
: role === 'professor'
|
: 'Esta conta possui acesso de instrutor. Selecione a opção Instrutor.');
|
||||||
? 'Esta conta não possui acesso de instrutor.'
|
|
||||||
: 'Esta conta possui outro nível de acesso. Selecione a opção correspondente.');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,10 +72,7 @@ export const LoginModal: React.FC<LoginModalProps> = ({ isOpen, onClose }) => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex bg-black/40 p-1 rounded-[8px] mb-6 border border-white/5 relative">
|
<div className="flex bg-black/40 p-1 rounded-[8px] mb-6 border border-white/5 relative">
|
||||||
<div
|
<div className={`absolute top-1 bottom-1 w-[calc(50%-4px)] bg-orange-500/20 rounded-[8px] transition-all duration-300 ease-out border border-orange-500/30 shadow-md ${role === 'student' ? 'left-1' : 'left-[calc(50%+4px)]'}`} />
|
||||||
className="absolute top-1 bottom-1 w-[calc(33.333%-5px)] bg-orange-500/20 rounded-[8px] transition-all duration-300 ease-out border border-orange-500/30 shadow-md"
|
|
||||||
style={{ transform: `translateX(${role === 'student' ? 0 : role === 'professor' ? 100 : 200}%)` }}
|
|
||||||
/>
|
|
||||||
<button type="button" onClick={() => setRole('student')} className={`flex-1 flex items-center justify-center gap-2 py-2.5 rounded-[8px] relative z-10 transition-colors duration-300 ${role === 'student' ? 'text-white font-semibold' : 'text-gray-400 hover:text-gray-300'}`}>
|
<button type="button" onClick={() => setRole('student')} className={`flex-1 flex items-center justify-center gap-2 py-2.5 rounded-[8px] relative z-10 transition-colors duration-300 ${role === 'student' ? 'text-white font-semibold' : 'text-gray-400 hover:text-gray-300'}`}>
|
||||||
<GraduationCap className="w-4 h-4" />
|
<GraduationCap className="w-4 h-4" />
|
||||||
<span className="text-body-sm font-semibold tracking-body-sm">Aluno</span>
|
<span className="text-body-sm font-semibold tracking-body-sm">Aluno</span>
|
||||||
@@ -86,10 +81,6 @@ export const LoginModal: React.FC<LoginModalProps> = ({ isOpen, onClose }) => {
|
|||||||
<School className="w-4 h-4" />
|
<School className="w-4 h-4" />
|
||||||
<span className="text-body-sm font-semibold tracking-body-sm">Instrutor</span>
|
<span className="text-body-sm font-semibold tracking-body-sm">Instrutor</span>
|
||||||
</button>
|
</button>
|
||||||
<button type="button" onClick={() => setRole('superadmin')} className={`flex-1 flex items-center justify-center gap-2 py-2.5 rounded-[8px] relative z-10 transition-colors duration-300 ${role === 'superadmin' ? 'text-white font-semibold' : 'text-gray-400 hover:text-gray-300'}`}>
|
|
||||||
<ShieldCheck className="w-4 h-4" />
|
|
||||||
<span className="text-body-sm font-semibold tracking-body-sm">Admin</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form onSubmit={handleSubmit} className="space-y-5">
|
<form onSubmit={handleSubmit} className="space-y-5">
|
||||||
|
|||||||
Reference in New Issue
Block a user