Ajout case à cocher CGU sur inscription et script création admin
- Inscription : checkbox obligatoire avec liens mentions légales et confidentialité - Script createAdmin.js pour créer le compte administrateur en base Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
33
backend/src/scripts/createAdmin.js
Normal file
33
backend/src/scripts/createAdmin.js
Normal file
@@ -0,0 +1,33 @@
|
||||
const bcrypt = require('bcrypt')
|
||||
const prisma = require('../config/prisma')
|
||||
|
||||
async function createAdmin() {
|
||||
const email = 'admin@thetiptop.fr'
|
||||
const password = 'Admin@TipTop2026!'
|
||||
|
||||
const existing = await prisma.user.findUnique({ where: { email } })
|
||||
if (existing) {
|
||||
console.log('Admin déjà existant :', email)
|
||||
return
|
||||
}
|
||||
|
||||
const hashed = await bcrypt.hash(password, 10)
|
||||
|
||||
await prisma.user.create({
|
||||
data: {
|
||||
firstname: 'Admin',
|
||||
lastname: 'TipTop',
|
||||
email,
|
||||
password: hashed,
|
||||
role: 'ADMIN',
|
||||
},
|
||||
})
|
||||
|
||||
console.log('✅ Admin créé avec succès')
|
||||
console.log(' Email :', email)
|
||||
console.log(' Mot de passe :', password)
|
||||
}
|
||||
|
||||
createAdmin()
|
||||
.catch((e) => { console.error('Erreur :', e.message); process.exit(1) })
|
||||
.finally(() => prisma.$disconnect())
|
||||
@@ -5,6 +5,7 @@ import { registerApi } from '../services/auth'
|
||||
export default function Inscription() {
|
||||
const navigate = useNavigate()
|
||||
const [form, setForm] = useState({ email: '', lastName: '', firstName: '', password: '' })
|
||||
const [acceptedTerms, setAcceptedTerms] = useState(false)
|
||||
const [showPassword, setShowPassword] = useState(false)
|
||||
const [error, setError] = useState('')
|
||||
const [loading, setLoading] = useState(false)
|
||||
@@ -132,9 +133,29 @@ export default function Inscription() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<label className="flex items-start gap-3 cursor-pointer">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={acceptedTerms}
|
||||
onChange={(e) => setAcceptedTerms(e.target.checked)}
|
||||
required
|
||||
className="mt-0.5 w-4 h-4 accent-[#006B6B] flex-shrink-0"
|
||||
/>
|
||||
<span className="text-xs text-gray-500 leading-relaxed">
|
||||
J'accepte les{' '}
|
||||
<Link to="/mentions-legales" className="text-[#006B6B] hover:underline font-medium">
|
||||
conditions d'utilisation
|
||||
</Link>{' '}
|
||||
et la{' '}
|
||||
<Link to="/confidentialite" className="text-[#006B6B] hover:underline font-medium">
|
||||
politique de confidentialité
|
||||
</Link>
|
||||
</span>
|
||||
</label>
|
||||
|
||||
<button
|
||||
type="submit"
|
||||
disabled={loading}
|
||||
disabled={loading || !acceptedTerms}
|
||||
className="w-full bg-[#006B6B] hover:bg-[#005959] disabled:opacity-60 text-white font-medium py-3 rounded-lg transition-colors"
|
||||
>
|
||||
{loading ? 'Inscription...' : "S'inscrire"}
|
||||
|
||||
Reference in New Issue
Block a user