react-redux-django-auth 1.2.0 → 1.3.1
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 +9 -9
- package/dist/index.js +5 -4
- package/dist/index.mjs +5 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ import React from 'react';
|
|
|
29
29
|
import ReactDOM from 'react-dom/client';
|
|
30
30
|
import { BrowserRouter } from 'react-router-dom';
|
|
31
31
|
import App from './App';
|
|
32
|
-
import AuthProvider from 'react-redux-django-auth'; // Add this import line
|
|
32
|
+
import {AuthProvider} from 'react-redux-django-auth'; // Add this import line
|
|
33
33
|
|
|
34
34
|
const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement);
|
|
35
35
|
|
|
@@ -59,7 +59,7 @@ The `useLogin` hook is a custom hook designed to manage the state and logic for
|
|
|
59
59
|
First, import the useLogin hook into your component. You'll need to define an object for your initial form state, which should match the expected fields for your login form (e.g., email, password), as required in your django backend.
|
|
60
60
|
|
|
61
61
|
```JavaScript
|
|
62
|
-
import useLogin from "react-redux-django-auth";
|
|
62
|
+
import {useLogin} from "react-redux-django-auth";
|
|
63
63
|
|
|
64
64
|
const initialFormData = {
|
|
65
65
|
email: "",
|
|
@@ -142,7 +142,7 @@ The `useSignup` hook is a custom hook designed to manage the state and logic for
|
|
|
142
142
|
First, import the `useSignup` hook into your component. You'll need to define an object for your initial form state, which should match the expected fields for your sign-up form (e.g., email, password, etc.).
|
|
143
143
|
|
|
144
144
|
```JavaScript
|
|
145
|
-
import useSignup from "react-redux-django-auth";
|
|
145
|
+
import {useSignup} from "react-redux-django-auth";
|
|
146
146
|
|
|
147
147
|
const initialFormData = {
|
|
148
148
|
// Add other fields as needed
|
|
@@ -216,7 +216,7 @@ The `useActivate` hook is a custom hook designed to handle the user account acti
|
|
|
216
216
|
First, import the `useActivate` hook into your component. Typically, account activation links contain `uid` and `token` parameters, which you can extract from the URL using `useParams` from `react-router-dom`.
|
|
217
217
|
|
|
218
218
|
```javascript
|
|
219
|
-
import useActivate from "react-redux-django-auth";
|
|
219
|
+
import { useActivate } from "react-redux-django-auth";
|
|
220
220
|
import { useParams } from "react-router-dom";
|
|
221
221
|
|
|
222
222
|
const ActivateAccount = () => {
|
|
@@ -276,7 +276,7 @@ The `useResetPassword` hook is designed to manage the state and logic for a pass
|
|
|
276
276
|
Call the `useResetPassword` hook inside your functional component, passing your API URL as an argument. The hook will return an object with all the necessary state and functions to build a password reset form.
|
|
277
277
|
|
|
278
278
|
```javascript
|
|
279
|
-
import useResetPassword from "react-redux-django-auth";
|
|
279
|
+
import { useResetPassword } from "react-redux-django-auth";
|
|
280
280
|
|
|
281
281
|
const ResetPasswordPage = () => {
|
|
282
282
|
const apiURL = process.env.REACT_APP_API_URL;
|
|
@@ -335,7 +335,7 @@ The `usePasswordConfirm` hook is designed to manage the state and logic for conf
|
|
|
335
335
|
First, import the `usePasswordConfirm` hook into your component. The hook requires an object for your initial form state, which should include fields for the new password, a confirmation field, and the `uid` and `token` from the URL.
|
|
336
336
|
|
|
337
337
|
```javascript
|
|
338
|
-
import usePasswordConfirm from "react-redux-django-auth";
|
|
338
|
+
import { usePasswordConfirm } from "react-redux-django-auth";
|
|
339
339
|
import { useParams } from "react-router-dom";
|
|
340
340
|
|
|
341
341
|
const ResetPasswordConfirm = () => {
|
|
@@ -417,7 +417,7 @@ The `useLogout` hook is a straightforward custom hook designed to handle user lo
|
|
|
417
417
|
First, import the `useLogout` hook into the component where you need to provide a logout function, such as a navigation bar or a user profile dropdown.
|
|
418
418
|
|
|
419
419
|
```javascript
|
|
420
|
-
import useLogout from "react-redux-django-auth";
|
|
420
|
+
import { useLogout } from "react-redux-django-auth";
|
|
421
421
|
```
|
|
422
422
|
|
|
423
423
|
#### 2\. Call the Hook in Your Component
|
|
@@ -460,7 +460,7 @@ The `useChangeAuthenticatedUserPassword` hook is a custom hook that simplifies t
|
|
|
460
460
|
First, import the `useChangeAuthenticatedUserPassword` hook into your component. Define an object for your initial form state that includes fields for the current password, a new password, and a confirmation of the new password.
|
|
461
461
|
|
|
462
462
|
```javascript
|
|
463
|
-
import useChangeAuthenticatedUserPassword from "react-redux-django-auth";
|
|
463
|
+
import { useChangeAuthenticatedUserPassword } from "react-redux-django-auth";
|
|
464
464
|
|
|
465
465
|
const initialFormData = {
|
|
466
466
|
current_password: "",
|
|
@@ -544,7 +544,7 @@ The `useAuthenticatedUser` hook is a central part of your authentication system,
|
|
|
544
544
|
First, import the `useAuthenticatedUser` hook into a high-level component that needs access to the user's data, such as a layout component or a dashboard. You'll need to pass the `apiURL` and the current `location` (typically from `react-router-dom`) to the hook.
|
|
545
545
|
|
|
546
546
|
```javascript
|
|
547
|
-
import useAuthenticatedUser from "react-redux-django-auth";
|
|
547
|
+
import { useAuthenticatedUser } from "react-redux-django-auth";
|
|
548
548
|
import { useLocation } from "react-router-dom";
|
|
549
549
|
|
|
550
550
|
const DashboardLayout = () => {
|
package/dist/index.js
CHANGED
|
@@ -1088,13 +1088,13 @@ var useLogin = function(initialFields, apiUrl) {
|
|
|
1088
1088
|
var _ref1 = _sliced_to_array((0, import_react2.useState)(initialFields), 2), formData = _ref1[0], setFormData = _ref1[1];
|
|
1089
1089
|
var dispatch = (0, import_react_redux2.useDispatch)();
|
|
1090
1090
|
var isAuthenticated = (0, import_react_redux2.useSelector)(function(state) {
|
|
1091
|
-
return state.isAuthenticated;
|
|
1091
|
+
return state.auth.isAuthenticated;
|
|
1092
1092
|
});
|
|
1093
1093
|
var error = (0, import_react_redux2.useSelector)(function(state) {
|
|
1094
|
-
return state.error;
|
|
1094
|
+
return state.auth.error;
|
|
1095
1095
|
});
|
|
1096
1096
|
var status = (0, import_react_redux2.useSelector)(function(state) {
|
|
1097
|
-
return state.status;
|
|
1097
|
+
return state.auth.status;
|
|
1098
1098
|
});
|
|
1099
1099
|
var isStatus200 = status === 200;
|
|
1100
1100
|
(0, import_react2.useEffect)(function() {
|
|
@@ -1976,9 +1976,10 @@ function authReducer() {
|
|
|
1976
1976
|
}
|
|
1977
1977
|
}
|
|
1978
1978
|
// src/reducers/index.ts
|
|
1979
|
-
var
|
|
1979
|
+
var rootReducer = (0, import_redux.combineReducers)({
|
|
1980
1980
|
auth: authReducer
|
|
1981
1981
|
});
|
|
1982
|
+
var reducers_default = rootReducer;
|
|
1982
1983
|
// src/store.ts
|
|
1983
1984
|
var initialState2 = {};
|
|
1984
1985
|
var store = (0, import_toolkit.configureStore)({
|
package/dist/index.mjs
CHANGED
|
@@ -354,10 +354,10 @@ var useLogin = (initialFields, apiUrl) => {
|
|
|
354
354
|
const [formData, setFormData] = useState2(initialFields);
|
|
355
355
|
const dispatch = useDispatch2();
|
|
356
356
|
const isAuthenticated = useSelector2(
|
|
357
|
-
(state) => state.isAuthenticated
|
|
357
|
+
(state) => state.auth.isAuthenticated
|
|
358
358
|
);
|
|
359
|
-
const error = useSelector2((state) => state.error);
|
|
360
|
-
const status = useSelector2((state) => state.status);
|
|
359
|
+
const error = useSelector2((state) => state.auth.error);
|
|
360
|
+
const status = useSelector2((state) => state.auth.status);
|
|
361
361
|
const isStatus200 = status === 200;
|
|
362
362
|
useEffect2(() => {
|
|
363
363
|
return () => {
|
|
@@ -856,9 +856,10 @@ function authReducer(state = initialState, action) {
|
|
|
856
856
|
}
|
|
857
857
|
|
|
858
858
|
// src/reducers/index.ts
|
|
859
|
-
var
|
|
859
|
+
var rootReducer = combineReducers({
|
|
860
860
|
auth: authReducer
|
|
861
861
|
});
|
|
862
|
+
var reducers_default = rootReducer;
|
|
862
863
|
|
|
863
864
|
// src/store.ts
|
|
864
865
|
var initialState2 = {};
|