This repository was archived by the owner on Jul 20, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaccount.php
More file actions
53 lines (47 loc) · 1.64 KB
/
Copy pathaccount.php
File metadata and controls
53 lines (47 loc) · 1.64 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
<?php include 'partials/header.php'; ?>
<main>
<h1>My account</h1>
<div id="loading">Loading account information...</div>
<!-- Sensitive information are not displayed until server is sure user is authenticated -->
<div id="account-content" style="display: none;">
<div class="account-details">
<div>
<label>First name</label>
<p id="user-first-name"></p>
</div>
<div>
<label>Last name</label>
<p id="user-last-name"></p>
</div>
<div>
<label>Email</label>
<p id="user-email"></p>
</div>
</div>
</div>
</main>
<script>
fetch('/account-data')
.then(response => {
// Session has been lost
if (response.status === 401) {
window.location.href = '/sign-in';
return;
}
return response.json();
})
.then(data => {
if (data && !data.error) {
document.getElementById('user-first-name').textContent = data.first_name;
document.getElementById('user-last-name').textContent = data.last_name;
document.getElementById('user-email').textContent = data.email;
document.getElementById('loading').style.display = 'none';
document.getElementById('account-content').style.display = 'block';
}
})
.catch(err => {
// Redirect if network issue
window.location.href = '/sign-in';
});
</script>
<?php include 'partials/footer.php'; ?>