-
Notifications
You must be signed in to change notification settings - Fork 0
/
unsubscribe.html
55 lines (55 loc) · 1.66 KB
/
unsubscribe.html
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
<!doctype html>
<html>
<head>
<title>Unsubscribe from FIN4Xplorer Notification Server</title>
<style>
html * {
font-family: arial;
}
</style>
<script src="/socket.io/socket.io.js"></script>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
</head>
<body>
<br>
<div id='info'>Loading...</div>
<br>
<input id="unsubscribeBtn" type="submit" value="Unsubscribe">
<br><br><br>
<div id='mainPage'></div>
<script>
$('#mainPage').html('Go to <a href="' + window.location.origin + '">' + window.location.origin.split('//')[1] + '</a>');
let socket = io();
let params = new window.URLSearchParams(window.location.search);
if (params.get('authKey')) {
socket.emit('check-email-auth-key', params.get('authKey'));
} else {
$('#info').html('No authentication key provided in the URL');
}
let user = {
validAuthKey: null,
email: null
};
socket.on('check-email-auth-key-result', _user => {
if (_user) {
$('#info').html('Press "Unsubscribe" to remove <i>' + _user.email + '</i> from the notification server');
user.validAuthKey = _user.authKey;
user.email = _user.email;
} else {
$('#info').html('No email found linked to the provided authentication key');
}
});
$('#unsubscribeBtn').click(() => {
if (!user.validAuthKey) {
$('#info').html('Can\'t unsubscribe without a valid authentication key');
return;
}
socket.emit('unsubscribe-email', user.validAuthKey);
console.log('Unsubscribing email from notifications server', user);
});
socket.on('unsubscribe-email-result', msg => {
$('#info').html(msg);
});
</script>
</body>
</html>