File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -113,3 +113,7 @@ exclude:
113113 - README.md
114114 - CNAME
115115 - vendor
116+
117+ include :
118+ - experimental/test-login.html
119+ - experimental/test-login.js
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="utf-8 " />
5+ < meta name ="viewport " content ="width=device-width, initial-scale=1 " />
6+ < title > Test Page</ title >
7+ < script src ="test-login.js " async ="true "> </ script >
8+ </ head >
9+ < body >
10+ < noscript > You need to enable JavaScript to run this app.</ noscript >
11+ < div id ="root "> </ div >
12+ </ body >
13+ </ html >
Original file line number Diff line number Diff line change 1+ console . log ( 'Starting test-login.js' ) ;
2+
3+ const rootDiv = document . getElementById ( 'root' ) ;
4+
5+ if ( ! rootDiv ) {
6+ throw new Error ( 'Root div not found' ) ;
7+ }
8+
9+ var cookieMap = { } ;
10+
11+ document . cookie
12+ . split ( ';' )
13+ . map ( function ( part ) {
14+ return part . trim ( ) . split ( '=' ) ;
15+ } )
16+ . forEach ( function ( pair ) {
17+ cookieMap [ pair [ 0 ] ] = decodeURIComponent ( pair [ 1 ] ) ;
18+ } ) ;
19+
20+ function htmlEncode ( text ) {
21+ const tempDiv = document . createElement ( 'div' ) ;
22+ tempDiv . innerText = text ;
23+ return tempDiv . innerHTML ;
24+ }
25+
26+ var loggedInUser = ( cookieMap [ 'rscommunity-logged-in-user' ] || '' ) . trim ( ) ;
27+
28+ var serviceUrl = '' ;
29+ if ( document . location . hostname . toUpperCase ( ) !== 'LOCALHOST' ) {
30+ serviceUrl = 'https://service.rushstack.io/' ;
31+ }
32+ var returnUrlQuery = 'returnUrl=' + encodeURIComponent ( document . location . pathname ) ;
33+
34+ if ( loggedInUser ) {
35+ // prettier-ignore
36+ rootDiv . innerHTML = 'You are logged in as <b>' + htmlEncode ( loggedInUser ) + '</b>.'
37+ + '<p>'
38+ + '<a href="' + serviceUrl + '/logout?' + returnUrlQuery + '">'
39+ + 'LOG OUT'
40+ + '</a>' ;
41+ } else {
42+ // prettier-ignore
43+ rootDiv . innerHTML = 'You are not logged in'
44+ + '<p>'
45+ + '<a href="' + serviceUrl + '/login?' + returnUrlQuery + '">'
46+ + 'LOG IN'
47+ + '</a>' ;
48+ }
You can’t perform that action at this time.
0 commit comments