2.0.1 • Published 2 years ago

ysauth v2.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

YsAuth Amplify (AWS Cognito User Pool) Authentication

This library is helper to aws amplify (with Cognito user pool) authentication with react

How To Use


first of all you need to create user pool on aws cognito

https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pool-as-user-directory.html


Provider

On top of your app need to add YsAuth Provider as describe below

First of all you need to import provider

import { YsAuthProvider } from 'ysauth';

Then impliment like this (for example)

<YsAuthProvider>
  <React.StrictMode>
    <App />
  </React.StrictMode>
</YsAuthProvider>

Configure Amplify

import { YsAuthAmpliftConfig } from 'ysauth';

And the configuration itself

YsAuthAmpliftConfig({
  region: '###',
  userPoolId: '###',
  userPoolWebClientId: '###',
  idleTime?: 10000 // time in milliseconds. default = 3600000 (1 hour)
});

That's It! 🚀

Now you can call useAuth wherever you want to use.

import { useAuth } from 'ysauth';

Uses

🔴 2.0 news

now you can get idle time out. by default JWT token of cognito user is 1 hour.

if the user is idle for 1 hour so auth.idle will be true

you can check if idle and the token is out of date.

if (auth.idle) {
  // do somthing... like popup to reload page
}
const auth = useAuth();

auth.loading;
auth.idle;
auth.getCurrentUser();
auth.login('username', 'password');
auth.signup('email', 'username', 'password');
auth.confirmSignup('username', 'code');
auth.logout();
auth.resetPassword('username', 'password', 'resetCode');
2.0.1

2 years ago

2.0.0

2 years ago

1.1.8

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago