Skip to content

Commit 506c281

Browse files
committed
Add popupless login to demo.
1 parent f832625 commit 506c281

File tree

3 files changed

+43
-23
lines changed

3 files changed

+43
-23
lines changed

demo/components/App.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @flow
22
import React from 'react'
33

4-
import LoginButton from './LoginButton'
4+
import AuthButtons from './AuthButtons'
55
import Copy from './Copy'
66
import PersonalInfo from './PersonalInfo'
77
import 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 />

demo/components/AuthButtons.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
}

demo/components/LoginButton.js

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)