forked from Zone01Rouen/greenit-emargement-audit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
executable file
·104 lines (87 loc) · 3.42 KB
/
Copy pathindex.php
File metadata and controls
executable file
·104 lines (87 loc) · 3.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php
require_once('PHP/config.php');
// Appel à /profile à CHAQUE chargement
$apiUrl = 'https://hub.zone01normandie.org/api/auth/profile';
$ch = curl_init($apiUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
if (isset($_SERVER['HTTP_COOKIE'])) {
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Cookie: ' . $_SERVER['HTTP_COOKIE']
]);
}
$response = curl_exec($ch);
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($statusCode === 200 && $response) {
$userData = json_decode($response, true);
// Toujours mettre à jour la session côté PHP avec les données actuelles
$_SESSION['user_emargement'] = [
'connected' => true,
'user_id' => $userData['id'],
'pseudo' => $userData['pseudo'],
'admin' => ($userData['role'] === 'Super Admin' || $userData['role'] === 'Admin') ? 1 : 0,
'statut' => $userData['statut'],
'role' => $userData['role']
];
header("Location: " . ($_SESSION['user_emargement']['admin'] == 1 ? "crud.php" : "user.php"));
exit;
}
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="CSS/bootstrap.min.css">
<title>Zone 01 - Connexion</title>
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/alertifyjs@1.13.1/build/css/alertify.min.css"/>
<link rel="stylesheet" href="CSS/style.css?v=2.21" type="text/css">
<link rel="icon" type="image/x-icon" href="image/favicon.ico">
</head>
<body>
<div class="connexion_container">
<div class="divLogoZ01">
<a href="index.php"><img class="logo" src="image/logo.png" alt="logo"></a>
</div>
<form id="loginForm" action="sign.php" method="post">
<div class="title">Connexion</div>
<label>Username</label>
<input type="text" name="pseudo" class="fill_input" required>
<label>Password</label>
<input type="password" name="password" class="fill_input" required>
<?php
if (isset($_SESSION['redirect_uri'])) {
echo '<input type="hidden" name="redirect_uri" value="' . $_SESSION['redirect_uri'] . '">';
unset($_SESSION['redirect_uri']);
}
?>
<input type="submit" value="Connexion" name="submit" class="connexion">
<a class="lostpwd" href="#" id="showResetForm">Mot de passe oublié ?</a>
</form>
<form id="resetForm" action="sign.php" method="post" class="d-none">
<div class="title">Mot de passe oublié</div>
<label>Email</label>
<input type="email" name="email" id="reset_pwd_email" class="fill_input" required>
<input type="submit" value="Reset password" name="submit" class="connexion">
<a class="lostpwd" href="#" id="showLoginForm">← Connexion</a>
</form>
</div>
</body>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/alertifyjs@1.13.1/build/alertify.min.js"></script>
<script src="JS/index.js?v=1.1"></script>
<?php
if(isset($_SESSION['error'])){
$error = $_SESSION['error'];
echo "<script>
alertify.set('notifier','position', 'top-center');
alertify.error('{$error}');
</script>";
unset($_SESSION['error']);
}
?>
</html>