File tree Expand file tree Collapse file tree 3 files changed +43
-23
lines changed
Expand file tree Collapse file tree 3 files changed +43
-23
lines changed Original file line number Diff line number Diff line change 11// @flow
22import React from 'react'
33
4- import LoginButton from './LoginButton '
4+ import AuthButtons from './AuthButtons '
55import Copy from './Copy'
66import PersonalInfo from './PersonalInfo'
77import Footer from './Footer'
@@ -10,7 +10,7 @@ const App = () => (
1010 < div >
1111 < nav >
1212 < h1 > Solid Auth Client Demo</ h1 >
13- < LoginButton />
13+ < AuthButtons />
1414 </ nav >
1515 < Copy />
1616 < PersonalInfo />
Original file line number Diff line number Diff line change 1+ // @flow
2+ import React from 'react'
3+ import auth from '../../src/'
4+
5+ const popupUri = process . env . POPUP_URI
6+
7+ export default class AuthButtons extends React . Component < Object , Object > {
8+ constructor ( props : { } ) {
9+ super ( props )
10+ auth . trackSession ( session => this . setState ( { loggedIn : ! ! session } ) )
11+ }
12+
13+ logout ( ) {
14+ auth . logout ( )
15+ }
16+
17+ login ( ) {
18+ const idp = window . prompt (
19+ 'What is the URL of your identity provider?' ,
20+ 'https://solidtest.space/'
21+ )
22+ if ( idp ) {
23+ auth . login ( idp )
24+ }
25+ }
26+
27+ popupLogin ( ) {
28+ auth . popupLogin ( { popupUri } )
29+ }
30+
31+ render ( ) {
32+ return this . state . loggedIn ? (
33+ < button onClick = { this . logout } > Log out</ button >
34+ ) : (
35+ < div >
36+ < button onClick = { this . login } > Log in</ button >
37+ < button onClick = { this . popupLogin } > Log in via popup</ button >
38+ </ div >
39+ )
40+ }
41+ }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments