1+ <!DOCTYPE html>
2+ < html >
3+ < head >
4+ < title > Ldnode: Admin Signup</ title >
5+ </ head >
6+
7+ < body >
8+
9+ < form id ="accounts ">
10+ < input type ="email ">
11+ </ form >
12+
13+ < form id ="cert " method ="POST " action ='/accounts/cert ' target ="spkacResult ">
14+ < keygen name ="spkac " >
15+ < input name ="webid ">
16+ < button onclick ='createGen() '> </ button >
17+ </ form >
18+
19+ < script type ="text/javascript ">
20+
21+ var email = document . querySelector ( "#email" ) . value
22+
23+ function createAccount ( email , callback ) {
24+ var hostname = location . hostname
25+ var url = '/accounts/new'
26+ var data = "email=" + email ;
27+
28+ var http = new XMLHttpRequest ( )
29+ http . open ( 'POST' , url )
30+ http . withCredentials = true
31+ http . setRequestHeader ( "Content-Type" , "application/x-www-form-urlencoded" )
32+ http . onreadystatechange = function ( ) {
33+ if ( this . readyState !== this . DONE
34+ || this . status !== 200 ) {
35+ return callback ( new Error ( 'Request failed' ) )
36+ }
37+ var webid = this . getResponseHeader ( "User" )
38+ if ( ! webid || webid . length === 0 ) {
39+ return callback ( new Error ( 'WebID is not set in User' ) )
40+ }
41+
42+ callback ( null , webid )
43+ // Account is created
44+ }
45+ http . send ( data ) ;
46+ }
47+
48+ function createGen ( ) {
49+ var iframe = document . createElement ( 'iframe' )
50+ iframe . name = 'spkacResult'
51+ iframe . style . visibility = 'none'
52+ iframe . style . width = '0px'
53+ iframe . style . height = '0px'
54+ document . querySelector ( 'body' ) . appendChild ( iframe )
55+
56+ iframe . onload = function ( ) {
57+ var done = document . createElement ( 'div' )
58+ done . innerHTML = '<p>restart your server without --signup</p>'
59+ document . querySelector ( 'body' ) . appendChild ( done )
60+ }
61+ }
62+
63+ document . querySelector ( '#cert' ) . style . display = 'none'
64+ createAccount ( email , function ( err , webid ) {
65+ document . querySelector ( '#accounts' ) . style . display = 'none'
66+ document . querySelector ( '#cert' ) . style . display = ''
67+ document . querySelector ( '#webid' ) . value = webid
68+ } )
69+ </ script >
70+ </ body >
71+ </ html >
0 commit comments