File tree 2 files changed +27
-12
lines changed
2 files changed +27
-12
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ import "./App.css"
3
3
import { IdentityModal , useNetlifyIdentity , IdentityContextProvider } from "react-netlify-identity-widget"
4
4
import "react-netlify-identity-widget/styles.css"
5
5
6
+
7
+
6
8
function App ( ) {
7
9
const [ dialog , setDialog ] = React . useState ( false )
8
10
const identity = useNetlifyIdentity ( "https://react-netlify-identity-widget.netlify.com" )
@@ -24,21 +26,20 @@ function App() {
24
26
>
25
27
LOG OUT
26
28
</ button >
27
- < IdentityModal showDialog = { dialog } onCloseDialog = { ( ) => setDialog ( false ) } />
28
29
</ >
29
30
) : (
30
- < >
31
- < h1 > hello! try logging in! </ h1 >
32
- < button
33
- className = "btn"
34
- style = { { maxWidth : 400 , background : "darkgreen" } }
35
- onClick = { ( ) => setDialog ( true ) }
36
- >
37
- LOG IN
31
+ < >
32
+ < h1 > hello! try logging in! </ h1 >
33
+ < button
34
+ className = "btn"
35
+ style = { { maxWidth : 400 , background : "darkgreen" } }
36
+ onClick = { ( ) => setDialog ( true ) }
37
+ >
38
+ LOG IN
38
39
</ button >
39
- < IdentityModal showDialog = { dialog } onCloseDialog = { ( ) => setDialog ( false ) } />
40
- </ >
41
- ) }
40
+ </ >
41
+ ) }
42
+ < IdentityModal showDialog = { dialog } onCloseDialog = { ( ) => setDialog ( false ) } />
42
43
< h3 >
43
44
Or{ " " }
44
45
< a
Original file line number Diff line number Diff line change 1
1
import React from "react"
2
2
import { useIdentityContext , SettingContext } from "../context"
3
3
import { Settings } from "react-netlify-identity"
4
+
5
+
6
+
7
+ const isLocalhost = Boolean (
8
+ window . location . hostname === 'localhost' ||
9
+ // [::1] is the IPv6 localhost address.
10
+ window . location . hostname === '[::1]' ||
11
+ // 127.0.0.1/8 is considered localhost for IPv4.
12
+ window . location . hostname . match (
13
+ / ^ 1 2 7 (?: \. (?: 2 5 [ 0 - 5 ] | 2 [ 0 - 4 ] [ 0 - 9 ] | [ 0 1 ] ? [ 0 - 9 ] [ 0 - 9 ] ? ) ) { 3 } $ /
14
+ )
15
+ ) ;
16
+
4
17
export function Providers ( ) {
5
18
const setting = React . useContext ( SettingContext )
6
19
const hasProviders =
@@ -10,6 +23,7 @@ export function Providers() {
10
23
if ( ! hasProviders ) return null
11
24
return (
12
25
< div className = "providersGroup" >
26
+ { isLocalhost && < pre > ⚠️Testing providers on localhost won't work because OAuth redirects to your production site</ pre > }
13
27
< hr className = "hr" />
14
28
< ProviderButton setting = { setting } provider = "Google" />
15
29
< ProviderButton setting = { setting } provider = "GitHub" />
You can’t perform that action at this time.
0 commit comments