Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: netlify-labs/react-netlify-identity
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.0.13
Choose a base ref
...
head repository: netlify-labs/react-netlify-identity
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.0.14
Choose a head ref
  • 3 commits
  • 5 files changed
  • 1 contributor

Commits on Apr 28, 2019

  1. bump version

    sw-yx committed Apr 28, 2019
    Copy the full SHA
    bee1f88 View commit details
  2. tryloginprovider

    sw-yx committed Apr 28, 2019
    Copy the full SHA
    b6523ff View commit details
  3. 0.0.14

    sw-yx committed Apr 28, 2019
    Copy the full SHA
    9615f07 View commit details
Showing with 27 additions and 11 deletions.
  1. +7 −0 CHANGELOG.md
  2. +1 −1 example/package.json
  3. +7 −4 example/src/App.tsx
  4. +1 −1 package.json
  5. +11 −5 src/index.tsx
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

## [v0.0.14](https://github.com/sw-yx/react-netlify-identity/compare/v0.0.13...v0.0.14) - 2019-04-28

### Commits

- tryloginprovider [`b6523ff`](https://github.com/sw-yx/react-netlify-identity/commit/b6523ff6cac9d1d09e549bc21055d32a1e6a1f29)
- bump version [`bee1f88`](https://github.com/sw-yx/react-netlify-identity/commit/bee1f888037ab22265874b7398e2dc051b9eb3b1)

## [v0.0.13](https://github.com/sw-yx/react-netlify-identity/compare/v0.0.12...v0.0.13) - 2019-04-28

### Commits
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
"private": true,
"dependencies": {
"@reach/router": "^1.2.1",
"react-netlify-identity": "^0.0.12",
"react-netlify-identity": "^0.0.13",
"react-scripts": "3.0.0",
"typescript": "3.4.5"
},
11 changes: 7 additions & 4 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react"
import { Router, Link, navigate } from "@reach/router"
import "./App.css"
import { useNetlifyIdentity } from "react-netlify-identity"
import { useNetlifyIdentity, Settings } from "react-netlify-identity"
import useLoading from "./useLoading"

let IdentityContext = React.createContext<ReturnType<typeof useNetlifyIdentity>>(undefined!)
@@ -20,13 +20,14 @@ function PrivateRoute(props: React.PropsWithoutRef<MaybePathProps & { as: React.
}

function Login({ }: MaybePathProps) {
const { loginUser, signupUser, settings } = React.useContext(IdentityContext)
const { loginUser, signupUser, settings, loginProvider } = React.useContext(IdentityContext)
const formRef = React.useRef<HTMLFormElement>(null!)
const [msg, setMsg] = React.useState("")
const [isLoading, load] = useLoading()
const [setting, setSetting] = React.useState<Settings | null>(null)
React.useEffect(() => {
settings().then((...args) => console.log({ args }))
}, [settings])
settings().then(x => setSetting(x))
}, [])
const signup = () => {
const email = formRef.current.email.value
const password = formRef.current.password.value
@@ -73,6 +74,8 @@ function Login({ }: MaybePathProps) {
{msg && <pre>{msg}</pre>}
</div>
)}
{setting && <pre>{JSON.stringify(setting, null, 2)}</pre>}
{setting && setting.external.github && <div onClick={() => loginProvider("github")}>GitHub</div>}
</form>
)
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-netlify-identity",
"version": "0.0.13",
"version": "0.0.14",
"description": "use netlify identity with react",
"author": "sw-yx",
"license": "MIT",
16 changes: 11 additions & 5 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react"

import GoTrue, { User } from "gotrue-js"
import GoTrue, { User, Settings } from "gotrue-js"

type authChangeParam = (user?: User) => string | void

@@ -10,6 +10,7 @@ interface NIProps {
onAuthChange?: authChangeParam
}

export type Settings = Settings
export type User = User
export default function NetlifyIdentity({ children, domain, onAuthChange }: NIProps) {
return children(useNetlifyIdentity(domain, onAuthChange))
@@ -34,10 +35,15 @@ export function useNetlifyIdentity(domain: string, onAuthChange: authChangeParam
}

/******* external oauth */
const loginExternalUrl = (provider: string) => goTrueInstance.loginExternalUrl(provider)
const acceptInviteExternalUrl = (provider: string, token: string) =>
type Provider = "bitbucket" | "facebook" | "github" | "gitlab" | "google"

const loginProvider = (provider: Provider) => {
const url = goTrueInstance.loginExternalUrl(provider)
if (window) window.location.href = url
}
const acceptInviteExternalUrl = (provider: Provider, token: string) =>
goTrueInstance.acceptInviteExternalUrl(provider, token)
const settings = goTrueInstance.settings.bind(goTrueInstance)
const settings: () => Promise<Settings> = goTrueInstance.settings.bind(goTrueInstance)

/******* OPERATIONS */
// make sure the Registration preferences under Identity settings in your Netlify dashboard are set to Open.
@@ -121,7 +127,7 @@ export function useNetlifyIdentity(domain: string, onAuthChange: authChangeParam
authedFetch,
_goTrueInstance: goTrueInstance,
_domain: domain,
loginExternalUrl,
loginProvider,
acceptInviteExternalUrl,
settings
}