react-redux-django-auth 1.1.0 → 1.2.0

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 ADDED
@@ -0,0 +1,605 @@
1
+ # React-Redux Authentication Hooks
2
+
3
+ This package provides a suite of custom React hooks and a Redux Provider to streamline authentication in your application. By integrating with Redux, it offers a predictable state management solution for handling user authentication status, data, and errors.
4
+
5
+ ### Installation
6
+
7
+ To get started, you'll need to install the package and its dependencies.
8
+
9
+ ```
10
+ npm install react-redux-django-auth react-redux redux axios
11
+ ```
12
+
13
+ or using yarn
14
+
15
+ ```
16
+ yarn add react-redux-django-auth react-redux redux axios
17
+ ```
18
+
19
+ # How to Use
20
+
21
+ The core of this package is the AuthProvider component. This component wraps your entire application, making the Redux store available to all child components. This is a crucial step for the authentication hooks to function correctly.
22
+
23
+ ## Wrap Your Application
24
+
25
+ The first step is to wrap your main App component with the AuthProvider. This is typically done in your entry file, such as `index.tsx` or `index.js`.
26
+
27
+ ```JavaScript
28
+ import React from 'react';
29
+ import ReactDOM from 'react-dom/client';
30
+ import { BrowserRouter } from 'react-router-dom';
31
+ import App from './App';
32
+ import AuthProvider from 'react-redux-django-auth'; // Add this import line
33
+
34
+ const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement);
35
+
36
+ root.render(
37
+ <React.StrictMode>
38
+ <BrowserRouter>
39
+ <AuthProvider>
40
+ <App />
41
+ </AuthProvider>
42
+ </BrowserRouter>
43
+ </React.StrictMode>
44
+ );
45
+ ```
46
+
47
+ By doing this, any component within your application can now access the authentication state and dispatch actions using the custom hooks provided by this package.
48
+
49
+ ## Using the Hooks
50
+
51
+ Once the AuthProvider is in place, you can use any of the custom hooks (like useFacebookAuth, useGoogleAuth, etc.) in your components. These hooks handle the logic for authentication, state management, and error handling, making your components cleaner and easier to maintain. For example, a login component might use the useFacebookAuth hook to initiate the login process.
52
+
53
+ ### Login Hook Usage
54
+
55
+ The `useLogin` hook is a custom hook designed to manage the state and logic for a login form, integrating directly with your Redux store for authentication. It handles form data, loading states, and dispatches login actions.
56
+
57
+ 1. Import the Hook and Set Up Initial State
58
+
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
+
61
+ ```JavaScript
62
+ import useLogin from "react-redux-django-auth";
63
+
64
+ const initialFormData = {
65
+ email: "",
66
+ password: "",
67
+ };
68
+ ```
69
+
70
+ 2. Call the Hook in Your Component
71
+
72
+ Call the useLogin hook inside your functional component, passing the initialFormData and your API URL as arguments. The hook will return an object containing everything you need to manage your login form.
73
+
74
+ ```JavaScript
75
+ const apiURL = process.env.REACT_APP_API_URL; //Setup REACT_APP_API_URL in .env
76
+
77
+ const LogIn = () => {
78
+ const initialFormData = {
79
+ email: "",
80
+ password: "",
81
+ };
82
+
83
+ const { error, formData, isStatus200, loading, onChange, onSubmit } =
84
+ useLogin(initialFormData, apiURL);
85
+
86
+ // ... rest of your component logic
87
+ };
88
+ ```
89
+
90
+ 3. Connect the Returned Values to Your Form
91
+
92
+ Now, use the values returned from the hook to manage your form's state and behavior.
93
+
94
+ - `formData:` Binds the input values to the form state.
95
+
96
+ - `onChange:` Updates the form state as the user types.
97
+
98
+ - `onSubmit:` Handles the form submission, dispatches the login action, and manages the loading state.
99
+
100
+ - `loading:` A boolean value to disable the submit button during a network request.
101
+
102
+ - `error:` Displays any authentication errors returned from the Redux state.
103
+
104
+ - `isStatus200:` If the `status` is `200`, perform actions like navigation to a new page
105
+
106
+ ```jsx
107
+ <form className="row g-3" onSubmit={(e) => onSubmit(e)}>
108
+ {/* Email Input */}
109
+ <input
110
+ type="email"
111
+ name="email"
112
+ onChange={(e) => onChange(e)}
113
+ value={formData.email}
114
+ required
115
+ />
116
+
117
+ {/* Password Input */}
118
+ <input
119
+ type="password"
120
+ name="password"
121
+ onChange={(e) => onChange(e)}
122
+ value={formData.password}
123
+ required
124
+ />
125
+
126
+ {/* Submit Button */}
127
+ <button type="submit" disabled={loading}>
128
+ {loading ? "Logging In..." : "Log In"}
129
+ </button>
130
+
131
+ {/* Display Error Message */}
132
+ {error && <div className="text-danger">{error}</div>}
133
+ </form>
134
+ ```
135
+
136
+ ### Signup Hook Usage
137
+
138
+ The `useSignup` hook is a custom hook designed to manage the state and logic for a user registration form. It integrates with your Redux store to handle form data, loading states, and dispatches sign-up actions.
139
+
140
+ 1. Import the Hook and Set Up Initial State
141
+
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
+
144
+ ```JavaScript
145
+ import useSignup from "react-redux-django-auth";
146
+
147
+ const initialFormData = {
148
+ // Add other fields as needed
149
+ email: "",
150
+ password: "",
151
+ re_password: "",
152
+ };
153
+ ```
154
+
155
+ 2. Call the Hook in Your Component
156
+ Call the useSignup hook inside your functional component, passing the initialFormData and your API URL as arguments. The hook will return an object containing everything you need to manage your sign-up form.
157
+
158
+ ```JavaScript
159
+ const apiURL = process.env.REACT_APP_API_URL;
160
+
161
+ const Signup = () => {
162
+ const initialFormData = {
163
+ // Add other fields as needed
164
+ email: "",
165
+ password: "",
166
+ re_password: "",
167
+ };
168
+
169
+ const { error, formData, isStatus201, loading, onChange, onSubmit } =
170
+ useSignup(initialFormData, apiURL);
171
+
172
+ // ... rest of your component logic
173
+ };
174
+ ```
175
+
176
+ 3. Connect the Returned Values to Your Form
177
+
178
+ Use the values returned from the hook to manage your form's state and behavior.
179
+
180
+ - `formData:` Binds the input values to the form state.
181
+
182
+ - `onChange:` Updates the form state as the user types.
183
+
184
+ - `onSubmit:` Handles the form submission, dispatches the sign-up action, and manages the loading state.
185
+
186
+ - `loading:` A boolean value to disable the submit button during a network request.
187
+
188
+ - `error:` Displays any authentication errors returned from the Redux state.
189
+
190
+ ```jsx
191
+ <form className="row g-3" onSubmit={(e) => onSubmit(e)}>
192
+ {/* Email Input */}
193
+ <input
194
+ type="email"
195
+ name="email"
196
+ onChange={(e) => onChange(e)}
197
+ value={formData.email}
198
+ required
199
+ />
200
+ // Add other form data
201
+ {/* Submit Button */}
202
+ <button type="submit" disabled={loading}>
203
+ {loading ? "Signing Up..." : "Sign Up"}
204
+ </button>
205
+ {/* Display Error Message */}
206
+ {error && <div className="text-danger">{error}</div>}
207
+ </form>
208
+ ```
209
+
210
+ ### `useActivate` Hook Usage
211
+
212
+ The `useActivate` hook is a custom hook designed to handle the user account activation process. It leverages Redux to dispatch the necessary `verify` action, manages the loading state during the API call, and provides feedback on the activation status and any errors.
213
+
214
+ #### 1\. Import the Hook and Get Parameters
215
+
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
+
218
+ ```javascript
219
+ import useActivate from "react-redux-django-auth";
220
+ import { useParams } from "react-router-dom";
221
+
222
+ const ActivateAccount = () => {
223
+ const { uid, token } = useParams();
224
+ const apiURL = process.env.REACT_APP_API_URL;
225
+ // ...
226
+ };
227
+ ```
228
+
229
+ #### 2\. Call the Hook in Your Component
230
+
231
+ Call the `useActivate` hook inside your functional component, passing the `uid`, `token`, and your API URL as arguments. The hook will return an object with the logic needed to manage the activation.
232
+
233
+ ```javascript
234
+ const { error, loading, onSubmit, isStatus204 } = useActivate(
235
+ uid,
236
+ token,
237
+ apiURL
238
+ );
239
+ ```
240
+
241
+ #### 3\. Connect the Returned Values to Your UI
242
+
243
+ Use the values returned from the hook to manage your component's state and behavior.
244
+
245
+ - `onSubmit`: This function triggers the account activation process. You should connect it to a button's `onClick` event.
246
+ - `loading`: A boolean value to disable the button and show a loading spinner while the API call is in progress.
247
+ - `error`: Displays any activation errors returned from the Redux state.
248
+ - `isStatus204`: A boolean that can be used to detect a successful activation (a `204 No Content` status is often used for successful, non-returning operations).
249
+
250
+ <!-- end list -->
251
+
252
+ ```jsx
253
+ <form onSubmit={onSubmit}>
254
+ {/* The button that triggers the activation */}
255
+ <button
256
+ type="submit"
257
+ onClick={onSubmit}
258
+ disabled={loading}
259
+ className={loading ? "btn btn-primary disabled" : "btn btn-primary"}
260
+ >
261
+ {loading && <LoaderIcon />}
262
+ Click here to Verify your Account
263
+ </button>
264
+
265
+ {/* Display Error Message */}
266
+ {error && <div className="text-danger">{error}</div>}
267
+ </form>
268
+ ```
269
+
270
+ ### `useResetPassword` Hook
271
+
272
+ The `useResetPassword` hook is designed to manage the state and logic for a password reset request. It provides a simple way to handle the email input, loading state, and the form submission process, dispatching a Redux action to request the password reset.
273
+
274
+ #### 1\. Call the Hook in Your Component
275
+
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
+
278
+ ```javascript
279
+ import useResetPassword from "react-redux-django-auth";
280
+
281
+ const ResetPasswordPage = () => {
282
+ const apiURL = process.env.REACT_APP_API_URL;
283
+ const { email, loading, handleChange, error, handleSubmit, isStatus204 } =
284
+ useResetPassword(apiURL);
285
+
286
+ // ... rest of your component logic
287
+ };
288
+ ```
289
+
290
+ #### 2\. Connect the Returned Values to Your Form
291
+
292
+ Use the values returned from the hook to manage your form's state and behavior.
293
+
294
+ - **`email`**: Binds the input value to the form state.
295
+ - **`handleChange`**: Updates the form state as the user types. This function is specifically for a single email input field.
296
+ - **`handleSubmit`**: Handles the form submission, dispatches the password reset action, and manages the loading state.
297
+ - **`loading`**: A boolean value to disable the submit button during the API request.
298
+ - **`error`**: Displays any authentication errors returned from the Redux state.
299
+ - **`isStatus204`**: A boolean value that becomes `true` upon a successful submission, useful for showing success messages or redirecting the user.
300
+
301
+ <!-- end list -->
302
+
303
+ ```jsx
304
+ <form onSubmit={handleSubmit}>
305
+ {/* Email Input */}
306
+ <input
307
+ type="email"
308
+ name="email"
309
+ onChange={handleChange}
310
+ value={email}
311
+ required
312
+ />
313
+
314
+ {/* Submit Button */}
315
+ <button type="submit" disabled={loading}>
316
+ {loading ? "Sending..." : "Reset Password"}
317
+ </button>
318
+
319
+ {/* Display Error Message */}
320
+ {error && <div className="text-danger">{error}</div>}
321
+
322
+ {/* Success Message (optional) */}
323
+ {isStatus204 && (
324
+ <div className="text-success">Password reset email sent!</div>
325
+ )}
326
+ </form>
327
+ ```
328
+
329
+ ### `usePasswordConfirm` Hook
330
+
331
+ The `usePasswordConfirm` hook is designed to manage the state and logic for confirming a new password after a reset request. This hook handles the form data for the new password fields, manages the loading state, and dispatches the necessary Redux action to finalize the password change.
332
+
333
+ #### 1\. Import the Hook and Set Up Initial State
334
+
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
+
337
+ ```javascript
338
+ import usePasswordConfirm from "react-redux-django-auth";
339
+ import { useParams } from "react-router-dom";
340
+
341
+ const ResetPasswordConfirm = () => {
342
+ const { uid, token } = useParams();
343
+ const apiURL = process.env.REACT_APP_API_URL;
344
+
345
+ const initialFormData = {
346
+ new_password: "",
347
+ re_new_password: "",
348
+ uid: uid,
349
+ token: token,
350
+ };
351
+
352
+ // ...
353
+ };
354
+ ```
355
+
356
+ #### 2\. Call the Hook in Your Component
357
+
358
+ Call the `usePasswordConfirm` hook inside your functional component, passing the `initialFormData` and your API URL as arguments. The hook will return an object with all the necessary state and functions to build the form.
359
+
360
+ ```javascript
361
+ const { loading, formData, error, onChange, onSubmit, isStatus204 } =
362
+ usePasswordConfirm(initialFormData, apiURL);
363
+ ```
364
+
365
+ #### 3\. Connect the Returned Values to Your Form
366
+
367
+ Use the values returned from the hook to manage your form's state and behavior.
368
+
369
+ - **`formData`**: Binds the input values to the form state.
370
+ - **`onChange`**: A function that updates the form state as the user types.
371
+ - **`onSubmit`**: Handles the form submission, dispatches the password confirmation action, and manages the loading state.
372
+ - **`loading`**: A boolean value to disable the submit button during a network request.
373
+ - **`error`**: Displays any authentication errors returned from the Redux state.
374
+ - **`isStatus204`**: A boolean that becomes `true` upon a successful submission, useful for showing success messages or redirecting the user.
375
+
376
+ <!-- end list -->
377
+
378
+ ```jsx
379
+ <form onSubmit={onSubmit}>
380
+ {/* New Password Input */}
381
+ <input
382
+ type="password"
383
+ name="new_password"
384
+ onChange={onChange}
385
+ value={formData.new_password}
386
+ required
387
+ />
388
+
389
+ {/* Confirm New Password Input */}
390
+ <input
391
+ type="password"
392
+ name="re_new_password"
393
+ onChange={onChange}
394
+ value={formData.re_new_password}
395
+ required
396
+ />
397
+
398
+ {/* Submit Button */}
399
+ <button type="submit" disabled={loading}>
400
+ {loading ? "Confirming..." : "Reset Password"}
401
+ </button>
402
+
403
+ {/* Display Error Message */}
404
+ {error && <div className="text-danger">{error}</div>}
405
+
406
+ {/* Success Message (optional) */}
407
+ {isStatus204 && <div className="text-success">Password has been reset!</div>}
408
+ </form>
409
+ ```
410
+
411
+ ### `useLogout` Hook
412
+
413
+ The `useLogout` hook is a straightforward custom hook designed to handle user logout. Its sole purpose is to dispatch the Redux action that clears the user's authentication state, making it a clean and reusable way to handle logouts across your application.
414
+
415
+ #### 1\. Import the Hook
416
+
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
+
419
+ ```javascript
420
+ import useLogout from "react-redux-django-auth";
421
+ ```
422
+
423
+ #### 2\. Call the Hook in Your Component
424
+
425
+ Call the `useLogout` hook inside your functional component. It doesn't take any arguments and returns a single function that you can attach to an event handler, such as a button's `onClick`.
426
+
427
+ ```javascript
428
+ const UserProfile = () => {
429
+ const logout = useLogout();
430
+
431
+ // ...
432
+ };
433
+ ```
434
+
435
+ #### 3\. Attach the Function to a Logout Button
436
+
437
+ Connect the `logout` function to a button or link that the user can click to sign out. When this function is called, it will dispatch the `logout` action to your Redux store, updating the application's authentication state.
438
+
439
+ ```jsx
440
+ const UserProfile = () => {
441
+ const logout = useLogout();
442
+
443
+ return (
444
+ <div>
445
+ <p>Welcome, User!</p>
446
+ <button onClick={logout}>Log Out</button>
447
+ </div>
448
+ );
449
+ };
450
+ ```
451
+
452
+ This approach simplifies your components by abstracting the Redux dispatch logic into a dedicated hook, keeping your UI code clean and focused on rendering.
453
+
454
+ ### `useChangeAuthenticatedUserPassword` Hook
455
+
456
+ The `useChangeAuthenticatedUserPassword` hook is a custom hook that simplifies the process of changing a user's password. It manages the form state for the current and new passwords, handles the loading state, and dispatches the necessary Redux action to update the password securely.
457
+
458
+ #### 1\. Import the Hook and Set Up Initial State
459
+
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
+
462
+ ```javascript
463
+ import useChangeAuthenticatedUserPassword from "react-redux-django-auth";
464
+
465
+ const initialFormData = {
466
+ current_password: "",
467
+ new_password: "",
468
+ confirm_new_password: "",
469
+ };
470
+ ```
471
+
472
+ #### 2\. Call the Hook in Your Component
473
+
474
+ Call the `useChangeAuthenticatedUserPassword` hook inside your functional component, passing the `initialFormData` and your API URL as arguments. The hook will return an object with all the state and functions needed to build the password change form.
475
+
476
+ ```javascript
477
+ const apiURL = process.env.REACT_APP_API_URL;
478
+
479
+ const ChangePasswordForm = () => {
480
+ const { loading, formData, error, onChange, onSubmit, status } =
481
+ useChangeAuthenticatedUserPassword(initialFormData, apiURL);
482
+
483
+ // ... rest of your component logic
484
+ };
485
+ ```
486
+
487
+ #### 3\. Connect the Returned Values to Your Form
488
+
489
+ Use the values returned from the hook to manage your form's state and behavior.
490
+
491
+ - **`formData`**: Binds the input values to the form state.
492
+ - **`onChange`**: A function that updates the form state as the user types.
493
+ - **`onSubmit`**: Handles the form submission, including validation to ensure the new passwords match, and dispatches the password change action.
494
+ - **`loading`**: A boolean value to disable the submit button while the API request is in progress.
495
+ - **`error`**: Displays any validation errors (e.g., mismatched passwords) or authentication errors returned from the Redux state.
496
+
497
+ <!-- end list -->
498
+
499
+ ```jsx
500
+ <form onSubmit={onSubmit}>
501
+ {/* Current Password Input */}
502
+ <input
503
+ type="password"
504
+ name="current_password"
505
+ onChange={onChange}
506
+ value={formData.current_password}
507
+ required
508
+ />
509
+
510
+ {/* New Password Input */}
511
+ <input
512
+ type="password"
513
+ name="new_password"
514
+ onChange={onChange}
515
+ value={formData.new_password}
516
+ required
517
+ />
518
+
519
+ {/* Confirm New Password Input */}
520
+ <input
521
+ type="password"
522
+ name="confirm_new_password"
523
+ onChange={onChange}
524
+ value={formData.confirm_new_password}
525
+ required
526
+ />
527
+
528
+ {/* Submit Button */}
529
+ <button type="submit" disabled={loading}>
530
+ {loading ? "Changing..." : "Change Password"}
531
+ </button>
532
+
533
+ {/* Display Error Message */}
534
+ {error && <div className="text-danger">{error}</div>}
535
+ </form>
536
+ ```
537
+
538
+ ### Documentation for `useAuthenticatedUser` Hook
539
+
540
+ The `useAuthenticatedUser` hook is a central part of your authentication system, designed to manage the user's authentication status and profile data. It automatically checks authentication on page load or URL changes and provides functions to manually refresh the user's data or re-authenticate.
541
+
542
+ #### 1\. Import the Hook and Call It in Your Component
543
+
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
+
546
+ ```javascript
547
+ import useAuthenticatedUser from "react-redux-django-auth";
548
+ import { useLocation } from "react-router-dom";
549
+
550
+ const DashboardLayout = () => {
551
+ const apiURL = process.env.REACT_APP_API_URL;
552
+ const location = useLocation();
553
+
554
+ const { isAuthenticated, currentUser, error, refreshUser } =
555
+ useAuthenticatedUser(apiURL, location);
556
+
557
+ // ...
558
+ };
559
+ ```
560
+
561
+ #### 2\. Access the Returned Values
562
+
563
+ The hook returns a comprehensive object that you can use to conditionally render content, display user information, and handle errors.
564
+
565
+ - **`isAuthenticated`**: A boolean (`true`, `false`, or `null` initially) that indicates if the user is authenticated.
566
+ - **`currentUser`**: An object containing the user's profile data once it has been loaded.
567
+ - **`error`**: Any authentication or profile-loading errors.
568
+ - **`refreshUser`**: A function to manually re-fetch the user's profile data. This is useful for refreshing a profile after an update.
569
+ - **`refreshAuth`**: A function to manually re-run the authentication check and then reload the user profile.
570
+ - **`clearErrors`**: A function to manually clear any authentication-related errors from the Redux state.
571
+
572
+ #### 3\. Example Usage
573
+
574
+ You can use these values to build a dynamic and responsive UI. For instance, you can display a loading state, show different content for authenticated and unauthenticated users, and provide a way for the user to refresh their profile.
575
+
576
+ ```jsx
577
+ const DashboardLayout = () => {
578
+ const apiURL = process.env.REACT_APP_API_URL;
579
+ const location = useLocation();
580
+
581
+ const { isAuthenticated, currentUser, error, refreshUser } =
582
+ useAuthenticatedUser(apiURL, location);
583
+
584
+ if (isAuthenticated === null) {
585
+ // Show a loading state while the initial check is happening
586
+ return <div>Checking authentication...</div>;
587
+ }
588
+
589
+ if (!isAuthenticated) {
590
+ // Redirect to login or show a "Please log in" message
591
+ return <Navigate to="/login" />;
592
+ }
593
+
594
+ // If isAuthenticated is true, currentUser will be available
595
+ return (
596
+ <div>
597
+ {error && <div className="text-danger">{error}</div>}
598
+ <h1>Welcome, {currentUser?.name}!</h1>
599
+ <button onClick={refreshUser}>Refresh Profile</button>
600
+ <nav>{/* Navigation links for authenticated users */}</nav>
601
+ {/* Rest of your dashboard content */}
602
+ </div>
603
+ );
604
+ };
605
+ ```
package/dist/index.d.mts CHANGED
@@ -34,9 +34,82 @@ interface SignupHookReturn {
34
34
  }
35
35
  declare const useSignup: (initialFields: any, apiUrl: string) => SignupHookReturn;
36
36
 
37
+ interface AuthHookReturn {
38
+ error: any;
39
+ isAuthenticated: boolean | null;
40
+ currentUser: any;
41
+ clearErrors: () => void;
42
+ refreshUser: () => void;
43
+ refreshAuth: () => Promise<void>;
44
+ }
45
+ declare const useAuthicatedUser: (apiURL: string, location: any) => AuthHookReturn;
46
+
47
+ interface ResetPasswordHookReturn {
48
+ email: string;
49
+ loading: boolean;
50
+ handleChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
51
+ status: any;
52
+ error: any;
53
+ handleSubmit: (e: React.FormEvent) => Promise<void>;
54
+ isStatus204: boolean;
55
+ }
56
+ declare const useResetPassword: (apiUrl: string) => ResetPasswordHookReturn;
57
+
58
+ interface FormData$1 {
59
+ new_password?: string;
60
+ re_new_password?: string;
61
+ uid?: string;
62
+ token?: string;
63
+ }
64
+ interface PasswordConfirmHookReturn {
65
+ loading: boolean;
66
+ formData: FormData$1;
67
+ error: any;
68
+ onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
69
+ onSubmit: (e: React.FormEvent) => Promise<void>;
70
+ status: any;
71
+ isStatus204: boolean;
72
+ }
73
+ declare const usePasswordConfirm: (initialFields: FormData$1, apiUrl: string) => PasswordConfirmHookReturn;
74
+
75
+ interface FormData {
76
+ current_password?: string;
77
+ new_password?: string;
78
+ confirm_new_password?: string;
79
+ }
80
+ interface ChangePasswordHookReturn {
81
+ loading: boolean;
82
+ formData: FormData;
83
+ error: string | null;
84
+ onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
85
+ onSubmit: (e: React.FormEvent) => Promise<void>;
86
+ status: any;
87
+ }
88
+ declare const useChangeAuthenticatedUserPassword: (initialFields: FormData, apiUrl: string) => ChangePasswordHookReturn;
89
+
90
+ interface GoogleAuthHookReturn {
91
+ continueWithGoogle: () => Promise<void>;
92
+ authenticateWithGoogle: (state: string, code: string) => Promise<void>;
93
+ isAuthenticated: boolean | null;
94
+ error: any;
95
+ isStatus201: boolean;
96
+ loading: boolean;
97
+ }
98
+ declare const useGoogleAuth: (apiUrl: string) => GoogleAuthHookReturn;
99
+
100
+ interface FacebookAuthHookReturn {
101
+ continueWithFacebook: () => Promise<void>;
102
+ authenticateWithFacebook: (state: string, code: string) => Promise<void>;
103
+ isAuthenticated: boolean | null;
104
+ error: any;
105
+ isStatus201: boolean;
106
+ loading: boolean;
107
+ }
108
+ declare const useFacebookAuth: (apiUrl: string) => FacebookAuthHookReturn;
109
+
37
110
  type AuthProviderProps = {
38
111
  children: React$1.ReactNode;
39
112
  };
40
113
  declare const AuthProvider: React$1.FC<AuthProviderProps>;
41
114
 
42
- export { AuthProvider, useActivate, useLogin, useLogout, useSignup };
115
+ export { AuthProvider, useActivate, useAuthicatedUser, useChangeAuthenticatedUserPassword, useFacebookAuth, useGoogleAuth, useLogin, useLogout, usePasswordConfirm, useResetPassword, useSignup };