Skip to content

Commit

Permalink
fixed Guard visible
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaoyiming0803 committed Sep 14, 2022
1 parent bb86961 commit 6492c06
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 3 deletions.
3 changes: 3 additions & 0 deletions examples/guard-react/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ function App() {
// host="https://guard-test-2022.authing.cn"
// redirectUri="http://localhost:3000/callback"
align="center"
config={{
mode: 'modal'
}}
>
<RouterComponent></RouterComponent>
</GuardProvider>
Expand Down
2 changes: 2 additions & 0 deletions examples/guard-react/src/pages/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { useGuard, Lang } from '@authing/guard-react'
export default function Login() {
const guard = useGuard()

console.log('guard: ', guard)

const [lang, setLang] = useState<Lang>('zh-CN')

useEffect(() => {
Expand Down
7 changes: 5 additions & 2 deletions examples/guard/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { GuardOptions } from '@authing/guard'
import { GuardOptions, GuardMode } from '@authing/guard'

export const guardOptions: GuardOptions = {
appId: '62e7f0c91073aaba0db4d65b',
// host: 'https://ipehegkanbpgkdho-demo.authing.cn',
align: 'center'
align: 'center',
config: {
mode: GuardMode.Modal
}
}
3 changes: 3 additions & 0 deletions examples/guard/src/pages/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ export default function Login () {

const onLogout = () => guard.logout()

const showGuardModal = () => guard.show()

return <>
<div style={{ marginBottom: '100px' }}>
<button onClick={onmountGuard}>unmount Guard Component</button>
Expand All @@ -70,6 +72,7 @@ export default function Login () {
<button onClick={getUserInfo}>getUserInfo</button>
<button onClick={checkLoginStatus}>checkLoginStatus</button>
<button onClick={onLogout}>onLogout</button>
<button onClick={showGuardModal}>show Guard Modal</button>
</div>

<div id="guard-container"></div>
Expand Down
2 changes: 1 addition & 1 deletion packages/guard/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class Guard {

this.then = init.then.bind(init)

this.visible = !!!(options.mode === GuardMode.Modal)
this.visible = !!(options.mode === GuardMode.Modal)
}

private async getPublicConfig(): Promise<{
Expand Down

0 comments on commit 6492c06

Please sign in to comment.