forked from yunganw/UserPoolAuth_UI_Test
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofile.html
More file actions
214 lines (182 loc) · 8.76 KB
/
profile.html
File metadata and controls
214 lines (182 loc) · 8.76 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
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
<html>
<head>
<title>User Profile Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<script>
//the function to detect dom ready, can use JQuery's document ready() method instead
new function(){
dom = [];
dom.isReady = false;
dom.isFunction = function(obj){
return Object.prototype.toString.call(obj) === "[object Function]";
}
dom.Ready = function(fn){
dom.initReady();
if(dom.isFunction(fn)){
if(dom.isReady){
fn();
}else{
dom.push(fn);
}
}
}
dom.fireReady =function(){
if (dom.isReady) return;
dom.isReady = true;
for(var i=0,n=dom.length;i<n;i++){
var fn = dom[i];
fn();
}
dom.length = 0;
}
dom.initReady = function(){
if (document.addEventListener) {
document.addEventListener( "DOMContentLoaded", function(){
document.removeEventListener( "DOMContentLoaded", arguments.callee, false );
dom.fireReady();
}, false );
}else{
if (document.getElementById) {
document.write("<script id=\"ie-domReady\" defer='defer'src=\"//:\"><\/script>");
document.getElementById("ie-domReady").onreadystatechange = function() {
if (this.readyState === "complete") {
dom.fireReady();
this.onreadystatechange = null;
this.parentNode.removeChild(this)
}
};
}
}
}
}
dom.Ready(function(){
getUserInfo();
});
function getAccessToken () {
if (!window.location.hash) {
return "";
}
var access_token = "" + window.location.hash.match(/access_token\=(.*?)(&|$)/)[1];
return access_token;
}
function getUserInfo () {
const uri = 'https://github.yungangwu.myinstance.com';
const path = '/oauth2/userInfo';
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", uri+path);
access_token = getAccessToken();
if ("" == access_token) {
document.getElementById("content").innerHTML="<h2>Error, please contact Application Admin</h2>";
return;
}
xmlhttp.setRequestHeader("Authorization", "Bearer "+access_token);
xmlhttp.onload = function(e) {
console.log ('get user response:' + this.status);
if (this.status == 200) {
var obj = JSON.parse(xmlhttp.responseText);
console.log ('obj:', JSON.stringify(obj));
document.getElementById("profileUserName").innerHTML = obj.username;
document.getElementsByName('email')[0].placeholder=obj.email;
document.getElementById("content").style.display = "block";
}
else {
document.getElementById("content").style.display = "block";
document.getElementById("content").innerHTML="<h2>Error, please contact Application Admin</h2>";
}
};
xmlhttp.onerror = function(e) {
console.log ('status: ' + this.status);
document.getElementById("content").style.display = "block";
document.getElementById("content").innerHTML="<h2>Error, please contact Application Admin</h2>";
};
xmlhttp.send(null);
}
</script>
<hr>
<div class="container bootstrap snippet" id='content' style="display:hidden;">
<div class="row">
<div class="col-sm-10"><h1 id='profileUserName'>User name</h1></div>
<div class="col-sm-2"><a href="#" class="pull-right"><img title="profile image" class="img-responsive" src="AWS_logo_RGB.png"></a></div>
</div>
<div class="row">
<div class="col-sm-3"><!--left col-->
<div class="text-center">
<img src="https://ssl.gstatic.com/accounts/ui/avatar_2x.png" class="avatar img-circle img-thumbnail" alt="avatar">
<h6>Upload a different photo...</h6>
<input type="file" class="text-center center-block file-upload">
</div></hr><br>
<div class="panel panel-default">
<div class="panel-heading">Status <i class="fa fa-link fa-1x"></i></div>
<div class="panel-body" id="userStatus"></div>
</div>
</div><!--/col-3-->
<div class="col-sm-9">
<hr>
<form class="form" action="##" method="post" id="registrationForm">
<div class="form-group">
<div class="col-xs-6">
<label for="first_name"><h4>First name</h4></label>
<input type="text" class="form-control" name="first_name" id="first_name" placeholder="first name" title="enter your first name if any.">
</div>
</div>
<div class="form-group">
<div class="col-xs-6">
<label for="last_name"><h4>Last name</h4></label>
<input type="text" class="form-control" name="last_name" id="last_name" placeholder="last name" title="enter your last name if any.">
</div>
</div>
<div class="form-group">
<div class="col-xs-6">
<label for="phone"><h4>Phone</h4></label>
<input type="text" class="form-control" name="phone" id="phone" placeholder="enter phone" title="enter your phone number if any.">
</div>
</div>
<div class="form-group">
<div class="col-xs-6">
<label for="mobile"><h4>Mobile</h4></label>
<input type="text" class="form-control" name="mobile" id="mobile" placeholder="enter mobile number" title="enter your mobile number if any.">
</div>
</div>
<div class="form-group">
<div class="col-xs-6">
<label for="email"><h4>Email</h4></label>
<input type="email" class="form-control" name="email" id="email" placeholder="you@email.com" title="enter your email.">
</div>
</div>
<div class="form-group">
<div class="col-xs-6">
<label for="address"><h4>Address</h4></label>
<input type="address" class="form-control" id="address" placeholder="somewhere" title="enter an address">
</div>
</div>
<div class="form-group">
<div class="col-xs-6">
<label for="password"><h4>Password</h4></label>
<input type="password" class="form-control" name="password" id="password" placeholder="password" title="enter your password.">
</div>
</div>
<div class="form-group">
<div class="col-xs-6">
<label for="password2"><h4>Verify</h4></label>
<input type="password" class="form-control" name="password2" id="password2" placeholder="password2" title="enter your password2.">
</div>
</div>
<div class="form-group">
<div class="col-xs-12">
<br>
<button class="btn btn-lg btn-success" type="submit"><i class="glyphicon glyphicon-ok-sign"></i> Save</button>
<button class="btn btn-lg" type="reset"><i class="glyphicon glyphicon-repeat"></i> Reset</button>
</div>
</div>
</form>
<hr>
</div><!--/col-9-->
</div><!--/row-->
</body>
</html>