react-redux-django-auth 1.4.6 → 1.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -604,7 +604,23 @@ const DashboardLayout = () => {
|
|
|
604
604
|
};
|
|
605
605
|
```
|
|
606
606
|
## React Native Usage
|
|
607
|
+
#### Setting Auth Provider
|
|
607
608
|
|
|
609
|
+
```
|
|
610
|
+
import { Slot } from "expo-router";
|
|
611
|
+
import AuthProviderNative from "./auth/AuthProviderNative";
|
|
612
|
+
|
|
613
|
+
export default function RootLayout() {
|
|
614
|
+
// Replace with your actual backend URL
|
|
615
|
+
const API_URL = "https://api.yourdomain.com/v1";
|
|
616
|
+
|
|
617
|
+
return (
|
|
618
|
+
<AuthProviderNative apiUrl={API_URL}>
|
|
619
|
+
<Slot />
|
|
620
|
+
</AuthProviderNative>
|
|
621
|
+
);
|
|
622
|
+
}
|
|
623
|
+
```
|
|
608
624
|
|
|
609
625
|
#### useBiometric hook
|
|
610
626
|
```
|
|
@@ -60,7 +60,8 @@ import { getBaseURL } from "../apis/config";
|
|
|
60
60
|
export var setupAuth = function (storage) {
|
|
61
61
|
var isRefreshing = false;
|
|
62
62
|
var failedQueue = [];
|
|
63
|
-
|
|
63
|
+
// 1. Declare the variable but don't initialize it yet
|
|
64
|
+
var api;
|
|
64
65
|
var processQueue = function (error, token) {
|
|
65
66
|
if (token === void 0) { token = null; }
|
|
66
67
|
failedQueue.forEach(function (prom) {
|
|
@@ -69,6 +70,9 @@ export var setupAuth = function (storage) {
|
|
|
69
70
|
failedQueue = [];
|
|
70
71
|
};
|
|
71
72
|
var initialize = function () {
|
|
73
|
+
// 2. Initialize the API here!
|
|
74
|
+
// This only runs when the user calls auth.initialize() in their App/Layout.
|
|
75
|
+
api = createApi(getBaseURL());
|
|
72
76
|
api.interceptors.request.use(function (config) { return __awaiter(void 0, void 0, void 0, function () {
|
|
73
77
|
var token;
|
|
74
78
|
return __generator(this, function (_a) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare const auth: {
|
|
2
2
|
initialize: () => void;
|
|
3
3
|
};
|
|
4
|
-
export { default as
|
|
4
|
+
export { default as AuthProviderNative } from './AuthProvider';
|
|
5
5
|
export { default as store } from './store';
|
|
6
6
|
export { default as useGoogleAuthNative } from './hooks/useGoogleAuth';
|
|
7
|
+
export { setBaseURL } from '../auth-core/apis/config';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { setupAuth } from '../auth-core/setup/setupAuth';
|
|
2
2
|
import { storage } from './storage/nativeStorage';
|
|
3
3
|
export var auth = setupAuth(storage);
|
|
4
|
-
export { default as
|
|
4
|
+
export { default as AuthProviderNative } from './AuthProvider';
|
|
5
5
|
export { default as store } from './store';
|
|
6
6
|
export { default as useGoogleAuthNative } from './hooks/useGoogleAuth';
|
|
7
|
+
export { setBaseURL } from '../auth-core/apis/config';
|