netlify-labs / react-netlify-identity

a tiny (4kb) React hook for using Netlify Identity, no UI. SEEKING MAINTAINERS
https://netlify-gotrue-in-react.netlify.com/
156 stars 25 forks source link

Merge pull request #30 from ljosberinn/master #30

Closed ljosberinn closed 4 years ago

ljosberinn commented 4 years ago

Hi,

this is in regard of #28 but also went above and beyond..

There is a token type for email_change, however there is no such function. I assume this is connected to the corresponding gotrue-js issue; should remove it from the interface for the time being then.

Planned usage would still be:

const { replace } = useHistory();
const { param: { token, type, error, status }, user } = useIdentityContext();

if(error) {
  // access denied
  console.log(status); // 403
  replace('/403');
  return null;
}

if(token) {
  switch(type) {
    case 'recovery':
        replace('/settings/change-password');
        break;
    case 'invite':
        // ...
        break;
    case 'email_change':
        // ...
        break;
  }

  return null;
}

Mainly I wanted to get this PR out so you can take a look at it, I'll probably not get to actually test it this week. Compiles fine though ofc.

swyxio commented 4 years ago

so sick!! merging and publishing. and inviting you to be collaborator!

swyxio commented 4 years ago

released v0.2