-
Notifications
You must be signed in to change notification settings - Fork 9
/
restricted.html
137 lines (109 loc) · 4.53 KB
/
restricted.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
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<html>
<head>
<title>Verify</title>
<!-- Bootstrap -->
<link rel="stylesheet" href="assets/css/bootstrap.min.css">
<link rel="stylesheet" href="assets/css/style.css">
</head>
<body>
<div class="container">
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">AWS User Pool Boilerplate</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li>
<a href="./index.html">Readme</a>
</li>
<li>
<a href="./login.html">Login</a>
</li>
<li>
<a href="./register.html">Register</a>
</li>
<li>
<a href="./verify.html">Verify</a>
</li>
<li class="active">
<a href="./restricted.html"><i class="glyphicon glyphicon-lock" id="res-icon" style="color:red"></i> Restricted Page</a>
</li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
<!--/.container-fluid -->
</nav>
<div class="col-md-3"></div>
<div class="well panel panel-danger col-md-6">
<button class="btn btn-danger" style="float:right" onclick = "signout();">Sign Out</button>
<div class="panel-body">
<center>
<h1>Restricted Area</h1>
<h2>Example-Dashboard</h2>
<h2 id="not_logged" class="label label-danger" style="font-size:20px">User Not Logged In</h2>
<h2 id="logged" class="label label-success" style="font-size:20px">User Logged In</h2>
<div id="data">
<h3>You are logged in as:</h3>
<h4 id="name">name</h4>
<h4 id="email">email</h4>
</div>
<br>
</center>
</div>
</div>
</div>
<!-- /container -->
<script src="assets/js/jquery-3.1.1.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/js/jsbn.js"></script>
<script src="assets/js/jsbn2.js"></script>
<script src="assets/js/sjcl.js"></script>
<script src="assets/js/aws-cognito-sdk.min.js"></script>
<script src="assets/js/amazon-cognito-identity.min.js"></script>
<script src="assets/js/aws-sdk-2.5.0.min.js"></script>
<script>
AWSCognito.config.region = 'eu-west-1';
var poolData = {
UserPoolId: 'eu-west-1_ZoHJNu0UM', // your user pool id here
ClientId: '6suoip8tmdsgv8gi64m42l9493' // your app client id here
};
var userPool = new AWSCognito.CognitoIdentityServiceProvider.CognitoUserPool(poolData);
var cognitoUser = userPool.getCurrentUser();
if (cognitoUser != null) {
cognitoUser.getSession(function(err, session) {
if (err) {
alert(err);
return;
}
$("#not_logged").css("display","none");
$("#res-icon").css("color","green");
});
}else{
$("#logged").css("display","none");
$("#data").css("display","none");
}
cognitoUser.getUserAttributes(function(err, result) {
if (err) {
alert(err);
return;
}
document.getElementById("name").innerHTML = result[2].getValue();
document.getElementById("email").innerHTML = result[3].getValue();
});
function signout () {
if (cognitoUser != null) {
cognitoUser.signOut();
location.reload();
}
}
</script>
</body>
</html>