@bagelink/auth 1.1.39 → 1.1.41
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/dist/index.cjs +43 -16
- package/dist/index.d.cts +88 -24
- package/dist/index.d.mts +88 -24
- package/dist/index.d.ts +88 -24
- package/dist/index.mjs +37 -17
- package/package.json +1 -1
- package/src/api/api.ts +11 -15
- package/src/api/auth.ts +53 -26
- package/src/composable/useAuth.ts +14 -11
- package/src/types.ts +79 -8
package/dist/index.cjs
CHANGED
|
@@ -1,14 +1,26 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
require('axios');
|
|
3
|
+
const axios = require('axios');
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
6
|
+
|
|
7
|
+
const axios__default = /*#__PURE__*/_interopDefaultCompat(axios);
|
|
8
|
+
|
|
9
|
+
const api$1 = void 0;
|
|
6
10
|
function getApi() {
|
|
7
11
|
if (!api$1) {
|
|
8
|
-
throw new Error("API not initialized. Call
|
|
12
|
+
throw new Error("API not initialized. Call initAuth first.");
|
|
9
13
|
}
|
|
10
14
|
return api$1;
|
|
11
15
|
}
|
|
16
|
+
function createDefaultApi(baseURL) {
|
|
17
|
+
return axios__default.create({
|
|
18
|
+
baseURL,
|
|
19
|
+
headers: {
|
|
20
|
+
"Content-Type": "application/json"
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
12
24
|
|
|
13
25
|
const ax = getApi();
|
|
14
26
|
ax.interceptors.request.use((config) => {
|
|
@@ -29,22 +41,23 @@ async function login(username, password) {
|
|
|
29
41
|
password
|
|
30
42
|
});
|
|
31
43
|
localStorage.setItem("access_token", data.access_token);
|
|
44
|
+
return { data };
|
|
32
45
|
}
|
|
33
46
|
function logout() {
|
|
34
47
|
localStorage.removeItem("access_token");
|
|
35
48
|
window.location.reload();
|
|
36
49
|
}
|
|
37
50
|
async function passwordRecovery(email) {
|
|
38
|
-
return ax.post(
|
|
51
|
+
return ax.post("/auth/password-recovery", { email });
|
|
39
52
|
}
|
|
40
53
|
async function resetPassword(newPassword) {
|
|
41
54
|
return ax.post("/auth/reset-password", { new_password: newPassword });
|
|
42
55
|
}
|
|
43
56
|
async function getCurrentUser() {
|
|
44
|
-
return ax.get("/
|
|
57
|
+
return ax.get("/users/me");
|
|
45
58
|
}
|
|
46
59
|
async function signup(user) {
|
|
47
|
-
return ax.post("/
|
|
60
|
+
return ax.post("/users/signup", {
|
|
48
61
|
email: user.email.toLowerCase(),
|
|
49
62
|
password: user.password,
|
|
50
63
|
first_name: user.first_name,
|
|
@@ -52,24 +65,33 @@ async function signup(user) {
|
|
|
52
65
|
});
|
|
53
66
|
}
|
|
54
67
|
async function updatePassword(form) {
|
|
55
|
-
return ax.
|
|
68
|
+
return ax.patch("/users/me/password", {
|
|
56
69
|
current_password: form.current_password,
|
|
57
70
|
new_password: form.new_password
|
|
58
71
|
});
|
|
59
72
|
}
|
|
60
73
|
async function updateUserProfile(user) {
|
|
61
|
-
return ax.
|
|
74
|
+
return ax.patch("/users/me", user);
|
|
62
75
|
}
|
|
63
76
|
async function setUserStatus(userId, isActive) {
|
|
64
|
-
return ax.patch(`/
|
|
77
|
+
return ax.patch(`/users/${userId}`, { is_active: isActive });
|
|
65
78
|
}
|
|
66
79
|
async function deleteUser(userId) {
|
|
67
|
-
return ax.delete(`/
|
|
80
|
+
return ax.delete(`/users/${userId}`);
|
|
81
|
+
}
|
|
82
|
+
async function getUsers(limit = 100, skip) {
|
|
83
|
+
return ax.get("/users/", { params: { skip, limit } });
|
|
84
|
+
}
|
|
85
|
+
async function createUser(user) {
|
|
86
|
+
return ax.post("/users/", user);
|
|
87
|
+
}
|
|
88
|
+
async function getUser(userId) {
|
|
89
|
+
return ax.get(`/users/${userId}`);
|
|
68
90
|
}
|
|
69
91
|
|
|
70
|
-
let api
|
|
71
|
-
let onError
|
|
72
|
-
let createRef
|
|
92
|
+
let api;
|
|
93
|
+
let onError;
|
|
94
|
+
let createRef;
|
|
73
95
|
const defaultReactiveFactory = (initial) => {
|
|
74
96
|
let value = initial;
|
|
75
97
|
return {
|
|
@@ -97,10 +119,12 @@ function createVueReactiveFactory(app) {
|
|
|
97
119
|
function initAuth({
|
|
98
120
|
axios,
|
|
99
121
|
errorHandler,
|
|
100
|
-
reactive = defaultReactiveFactory
|
|
122
|
+
reactive = defaultReactiveFactory,
|
|
123
|
+
baseURL
|
|
101
124
|
} = {}) {
|
|
102
|
-
api = axios ||
|
|
103
|
-
|
|
125
|
+
api = axios || createDefaultApi(baseURL);
|
|
126
|
+
if (errorHandler)
|
|
127
|
+
onError = errorHandler;
|
|
104
128
|
createRef = reactive;
|
|
105
129
|
return {
|
|
106
130
|
install(app) {
|
|
@@ -255,8 +279,11 @@ function useAuth() {
|
|
|
255
279
|
};
|
|
256
280
|
}
|
|
257
281
|
|
|
282
|
+
exports.createUser = createUser;
|
|
258
283
|
exports.deleteUser = deleteUser;
|
|
259
284
|
exports.getCurrentUser = getCurrentUser;
|
|
285
|
+
exports.getUser = getUser;
|
|
286
|
+
exports.getUsers = getUsers;
|
|
260
287
|
exports.initAuth = initAuth;
|
|
261
288
|
exports.login = login;
|
|
262
289
|
exports.logout = logout;
|
package/dist/index.d.cts
CHANGED
|
@@ -3,10 +3,10 @@ import { AxiosResponse, AxiosInstance } from 'axios';
|
|
|
3
3
|
interface User {
|
|
4
4
|
id: string;
|
|
5
5
|
email: string;
|
|
6
|
-
first_name
|
|
7
|
-
last_name
|
|
8
|
-
is_superuser
|
|
9
|
-
is_active
|
|
6
|
+
first_name?: string;
|
|
7
|
+
last_name?: string;
|
|
8
|
+
is_superuser?: boolean;
|
|
9
|
+
is_active?: boolean;
|
|
10
10
|
}
|
|
11
11
|
interface UserRegister {
|
|
12
12
|
email: string;
|
|
@@ -22,38 +22,102 @@ interface UpdatePasswordForm {
|
|
|
22
22
|
new_password: string;
|
|
23
23
|
confirmNewPassword: string;
|
|
24
24
|
}
|
|
25
|
-
interface
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
interface ReactiveFactory {
|
|
26
|
+
<T>(initial: T): {
|
|
27
|
+
value: T;
|
|
28
|
+
set: (newValue: T) => void;
|
|
29
|
+
};
|
|
28
30
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
interface Token {
|
|
32
|
+
access_token: string;
|
|
33
|
+
}
|
|
34
|
+
interface PasswordRecovery {
|
|
35
|
+
email: string;
|
|
36
|
+
}
|
|
37
|
+
interface NewPassword {
|
|
33
38
|
new_password: string;
|
|
34
39
|
}
|
|
35
|
-
|
|
40
|
+
interface UserUpdate {
|
|
41
|
+
email?: string;
|
|
42
|
+
is_active?: boolean;
|
|
43
|
+
is_superuser?: boolean;
|
|
44
|
+
first_name?: string;
|
|
45
|
+
last_name?: string;
|
|
46
|
+
}
|
|
47
|
+
interface UserUpdateMe {
|
|
48
|
+
email?: string;
|
|
49
|
+
first_name?: string;
|
|
50
|
+
last_name?: string;
|
|
51
|
+
}
|
|
52
|
+
interface UpdatePassword {
|
|
53
|
+
current_password: string;
|
|
54
|
+
new_password: string;
|
|
55
|
+
}
|
|
56
|
+
interface UserCreate {
|
|
57
|
+
email: string;
|
|
58
|
+
password: string;
|
|
59
|
+
first_name?: string;
|
|
60
|
+
last_name?: string;
|
|
61
|
+
is_active?: boolean;
|
|
62
|
+
is_superuser?: boolean;
|
|
63
|
+
}
|
|
64
|
+
interface SanitizedUserOut {
|
|
65
|
+
email: string;
|
|
66
|
+
is_active?: boolean;
|
|
67
|
+
is_superuser?: boolean;
|
|
68
|
+
first_name?: string;
|
|
69
|
+
last_name?: string;
|
|
70
|
+
id: string;
|
|
71
|
+
}
|
|
72
|
+
interface SanitizedUserList {
|
|
73
|
+
data: SanitizedUserOut[];
|
|
74
|
+
count: number;
|
|
75
|
+
}
|
|
76
|
+
type LoginResponse = AxiosResponse<Token>;
|
|
77
|
+
type PasswordRecoveryResponse = AxiosResponse;
|
|
78
|
+
type ResetPasswordResponse = AxiosResponse;
|
|
79
|
+
type GetUserResponse = AxiosResponse<SanitizedUserOut>;
|
|
80
|
+
type UpdateUserResponse = AxiosResponse<SanitizedUserOut>;
|
|
81
|
+
type DeleteUserResponse = AxiosResponse;
|
|
82
|
+
type GetUsersResponse = AxiosResponse<SanitizedUserList>;
|
|
83
|
+
type CreateUserResponse = AxiosResponse<SanitizedUserOut>;
|
|
84
|
+
type GetMeResponse = AxiosResponse<SanitizedUserOut>;
|
|
85
|
+
type UpdateMeResponse = AxiosResponse<SanitizedUserOut>;
|
|
86
|
+
type UpdatePasswordResponse = AxiosResponse;
|
|
87
|
+
type SignupResponse = AxiosResponse<SanitizedUserOut>;
|
|
88
|
+
|
|
89
|
+
declare function login(username: string, password: string): Promise<LoginResponse>;
|
|
36
90
|
declare function logout(): void;
|
|
37
|
-
declare function passwordRecovery(email?: string): Promise<
|
|
38
|
-
declare function resetPassword(newPassword:
|
|
39
|
-
declare function getCurrentUser(): Promise<
|
|
40
|
-
declare function signup(user: NewUser): Promise<
|
|
41
|
-
declare function updatePassword(form: UpdatePasswordForm): Promise<
|
|
42
|
-
declare function updateUserProfile(user: Partial<User>): Promise<
|
|
43
|
-
declare function setUserStatus(userId: string, isActive: boolean): Promise<
|
|
44
|
-
declare function deleteUser(userId: string): Promise<
|
|
91
|
+
declare function passwordRecovery(email?: string): Promise<PasswordRecoveryResponse>;
|
|
92
|
+
declare function resetPassword(newPassword: NewPassword['new_password']): Promise<ResetPasswordResponse>;
|
|
93
|
+
declare function getCurrentUser(): Promise<GetMeResponse>;
|
|
94
|
+
declare function signup(user: NewUser): Promise<SignupResponse>;
|
|
95
|
+
declare function updatePassword(form: UpdatePasswordForm): Promise<UpdatePasswordResponse>;
|
|
96
|
+
declare function updateUserProfile(user: Partial<User>): Promise<UpdateMeResponse>;
|
|
97
|
+
declare function setUserStatus(userId: string, isActive: boolean): Promise<UpdateUserResponse>;
|
|
98
|
+
declare function deleteUser(userId: string): Promise<DeleteUserResponse>;
|
|
99
|
+
declare function getUsers(limit?: number, skip?: number): Promise<GetUsersResponse>;
|
|
100
|
+
declare function createUser(user: UserCreate): Promise<CreateUserResponse>;
|
|
101
|
+
declare function getUser(userId: string): Promise<GetUserResponse>;
|
|
45
102
|
|
|
46
|
-
declare function initAuth({ axios, errorHandler, reactive }?: {
|
|
103
|
+
declare function initAuth({ axios, errorHandler, reactive, baseURL }?: {
|
|
47
104
|
axios?: AxiosInstance;
|
|
48
105
|
errorHandler?: (error: any) => void;
|
|
49
106
|
reactive?: ReactiveFactory;
|
|
107
|
+
baseURL?: string;
|
|
50
108
|
}): {
|
|
51
109
|
install(app: any): void;
|
|
52
110
|
useAuth: typeof useAuth;
|
|
53
111
|
};
|
|
54
112
|
declare function useAuth(): {
|
|
55
|
-
currentUser:
|
|
56
|
-
|
|
113
|
+
currentUser: {
|
|
114
|
+
value: User;
|
|
115
|
+
set: (newValue: User) => void;
|
|
116
|
+
};
|
|
117
|
+
passwordForm: {
|
|
118
|
+
value: UpdatePasswordForm;
|
|
119
|
+
set: (newValue: UpdatePasswordForm) => void;
|
|
120
|
+
};
|
|
57
121
|
getFullName: () => string;
|
|
58
122
|
getIsLoggedIn: () => boolean;
|
|
59
123
|
logout: () => Promise<void>;
|
|
@@ -71,4 +135,4 @@ declare function useAuth(): {
|
|
|
71
135
|
deleteUser: (userId: string) => Promise<void>;
|
|
72
136
|
};
|
|
73
137
|
|
|
74
|
-
export { type
|
|
138
|
+
export { type CreateUserResponse, type DeleteUserResponse, type GetMeResponse, type GetUserResponse, type GetUsersResponse, type LoginResponse, type NewPassword, type NewUser, type PasswordRecovery, type PasswordRecoveryResponse, type ReactiveFactory, type ResetPasswordResponse, type SanitizedUserList, type SanitizedUserOut, type SignupResponse, type Token, type UpdateMeResponse, type UpdatePassword, type UpdatePasswordForm, type UpdatePasswordResponse, type UpdateUserResponse, type User, type UserCreate, type UserRegister, type UserUpdate, type UserUpdateMe, createUser, deleteUser, getCurrentUser, getUser, getUsers, initAuth, login, logout, passwordRecovery, resetPassword, setUserStatus, signup, updatePassword, updateUserProfile, useAuth };
|
package/dist/index.d.mts
CHANGED
|
@@ -3,10 +3,10 @@ import { AxiosResponse, AxiosInstance } from 'axios';
|
|
|
3
3
|
interface User {
|
|
4
4
|
id: string;
|
|
5
5
|
email: string;
|
|
6
|
-
first_name
|
|
7
|
-
last_name
|
|
8
|
-
is_superuser
|
|
9
|
-
is_active
|
|
6
|
+
first_name?: string;
|
|
7
|
+
last_name?: string;
|
|
8
|
+
is_superuser?: boolean;
|
|
9
|
+
is_active?: boolean;
|
|
10
10
|
}
|
|
11
11
|
interface UserRegister {
|
|
12
12
|
email: string;
|
|
@@ -22,38 +22,102 @@ interface UpdatePasswordForm {
|
|
|
22
22
|
new_password: string;
|
|
23
23
|
confirmNewPassword: string;
|
|
24
24
|
}
|
|
25
|
-
interface
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
interface ReactiveFactory {
|
|
26
|
+
<T>(initial: T): {
|
|
27
|
+
value: T;
|
|
28
|
+
set: (newValue: T) => void;
|
|
29
|
+
};
|
|
28
30
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
interface Token {
|
|
32
|
+
access_token: string;
|
|
33
|
+
}
|
|
34
|
+
interface PasswordRecovery {
|
|
35
|
+
email: string;
|
|
36
|
+
}
|
|
37
|
+
interface NewPassword {
|
|
33
38
|
new_password: string;
|
|
34
39
|
}
|
|
35
|
-
|
|
40
|
+
interface UserUpdate {
|
|
41
|
+
email?: string;
|
|
42
|
+
is_active?: boolean;
|
|
43
|
+
is_superuser?: boolean;
|
|
44
|
+
first_name?: string;
|
|
45
|
+
last_name?: string;
|
|
46
|
+
}
|
|
47
|
+
interface UserUpdateMe {
|
|
48
|
+
email?: string;
|
|
49
|
+
first_name?: string;
|
|
50
|
+
last_name?: string;
|
|
51
|
+
}
|
|
52
|
+
interface UpdatePassword {
|
|
53
|
+
current_password: string;
|
|
54
|
+
new_password: string;
|
|
55
|
+
}
|
|
56
|
+
interface UserCreate {
|
|
57
|
+
email: string;
|
|
58
|
+
password: string;
|
|
59
|
+
first_name?: string;
|
|
60
|
+
last_name?: string;
|
|
61
|
+
is_active?: boolean;
|
|
62
|
+
is_superuser?: boolean;
|
|
63
|
+
}
|
|
64
|
+
interface SanitizedUserOut {
|
|
65
|
+
email: string;
|
|
66
|
+
is_active?: boolean;
|
|
67
|
+
is_superuser?: boolean;
|
|
68
|
+
first_name?: string;
|
|
69
|
+
last_name?: string;
|
|
70
|
+
id: string;
|
|
71
|
+
}
|
|
72
|
+
interface SanitizedUserList {
|
|
73
|
+
data: SanitizedUserOut[];
|
|
74
|
+
count: number;
|
|
75
|
+
}
|
|
76
|
+
type LoginResponse = AxiosResponse<Token>;
|
|
77
|
+
type PasswordRecoveryResponse = AxiosResponse;
|
|
78
|
+
type ResetPasswordResponse = AxiosResponse;
|
|
79
|
+
type GetUserResponse = AxiosResponse<SanitizedUserOut>;
|
|
80
|
+
type UpdateUserResponse = AxiosResponse<SanitizedUserOut>;
|
|
81
|
+
type DeleteUserResponse = AxiosResponse;
|
|
82
|
+
type GetUsersResponse = AxiosResponse<SanitizedUserList>;
|
|
83
|
+
type CreateUserResponse = AxiosResponse<SanitizedUserOut>;
|
|
84
|
+
type GetMeResponse = AxiosResponse<SanitizedUserOut>;
|
|
85
|
+
type UpdateMeResponse = AxiosResponse<SanitizedUserOut>;
|
|
86
|
+
type UpdatePasswordResponse = AxiosResponse;
|
|
87
|
+
type SignupResponse = AxiosResponse<SanitizedUserOut>;
|
|
88
|
+
|
|
89
|
+
declare function login(username: string, password: string): Promise<LoginResponse>;
|
|
36
90
|
declare function logout(): void;
|
|
37
|
-
declare function passwordRecovery(email?: string): Promise<
|
|
38
|
-
declare function resetPassword(newPassword:
|
|
39
|
-
declare function getCurrentUser(): Promise<
|
|
40
|
-
declare function signup(user: NewUser): Promise<
|
|
41
|
-
declare function updatePassword(form: UpdatePasswordForm): Promise<
|
|
42
|
-
declare function updateUserProfile(user: Partial<User>): Promise<
|
|
43
|
-
declare function setUserStatus(userId: string, isActive: boolean): Promise<
|
|
44
|
-
declare function deleteUser(userId: string): Promise<
|
|
91
|
+
declare function passwordRecovery(email?: string): Promise<PasswordRecoveryResponse>;
|
|
92
|
+
declare function resetPassword(newPassword: NewPassword['new_password']): Promise<ResetPasswordResponse>;
|
|
93
|
+
declare function getCurrentUser(): Promise<GetMeResponse>;
|
|
94
|
+
declare function signup(user: NewUser): Promise<SignupResponse>;
|
|
95
|
+
declare function updatePassword(form: UpdatePasswordForm): Promise<UpdatePasswordResponse>;
|
|
96
|
+
declare function updateUserProfile(user: Partial<User>): Promise<UpdateMeResponse>;
|
|
97
|
+
declare function setUserStatus(userId: string, isActive: boolean): Promise<UpdateUserResponse>;
|
|
98
|
+
declare function deleteUser(userId: string): Promise<DeleteUserResponse>;
|
|
99
|
+
declare function getUsers(limit?: number, skip?: number): Promise<GetUsersResponse>;
|
|
100
|
+
declare function createUser(user: UserCreate): Promise<CreateUserResponse>;
|
|
101
|
+
declare function getUser(userId: string): Promise<GetUserResponse>;
|
|
45
102
|
|
|
46
|
-
declare function initAuth({ axios, errorHandler, reactive }?: {
|
|
103
|
+
declare function initAuth({ axios, errorHandler, reactive, baseURL }?: {
|
|
47
104
|
axios?: AxiosInstance;
|
|
48
105
|
errorHandler?: (error: any) => void;
|
|
49
106
|
reactive?: ReactiveFactory;
|
|
107
|
+
baseURL?: string;
|
|
50
108
|
}): {
|
|
51
109
|
install(app: any): void;
|
|
52
110
|
useAuth: typeof useAuth;
|
|
53
111
|
};
|
|
54
112
|
declare function useAuth(): {
|
|
55
|
-
currentUser:
|
|
56
|
-
|
|
113
|
+
currentUser: {
|
|
114
|
+
value: User;
|
|
115
|
+
set: (newValue: User) => void;
|
|
116
|
+
};
|
|
117
|
+
passwordForm: {
|
|
118
|
+
value: UpdatePasswordForm;
|
|
119
|
+
set: (newValue: UpdatePasswordForm) => void;
|
|
120
|
+
};
|
|
57
121
|
getFullName: () => string;
|
|
58
122
|
getIsLoggedIn: () => boolean;
|
|
59
123
|
logout: () => Promise<void>;
|
|
@@ -71,4 +135,4 @@ declare function useAuth(): {
|
|
|
71
135
|
deleteUser: (userId: string) => Promise<void>;
|
|
72
136
|
};
|
|
73
137
|
|
|
74
|
-
export { type
|
|
138
|
+
export { type CreateUserResponse, type DeleteUserResponse, type GetMeResponse, type GetUserResponse, type GetUsersResponse, type LoginResponse, type NewPassword, type NewUser, type PasswordRecovery, type PasswordRecoveryResponse, type ReactiveFactory, type ResetPasswordResponse, type SanitizedUserList, type SanitizedUserOut, type SignupResponse, type Token, type UpdateMeResponse, type UpdatePassword, type UpdatePasswordForm, type UpdatePasswordResponse, type UpdateUserResponse, type User, type UserCreate, type UserRegister, type UserUpdate, type UserUpdateMe, createUser, deleteUser, getCurrentUser, getUser, getUsers, initAuth, login, logout, passwordRecovery, resetPassword, setUserStatus, signup, updatePassword, updateUserProfile, useAuth };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,10 +3,10 @@ import { AxiosResponse, AxiosInstance } from 'axios';
|
|
|
3
3
|
interface User {
|
|
4
4
|
id: string;
|
|
5
5
|
email: string;
|
|
6
|
-
first_name
|
|
7
|
-
last_name
|
|
8
|
-
is_superuser
|
|
9
|
-
is_active
|
|
6
|
+
first_name?: string;
|
|
7
|
+
last_name?: string;
|
|
8
|
+
is_superuser?: boolean;
|
|
9
|
+
is_active?: boolean;
|
|
10
10
|
}
|
|
11
11
|
interface UserRegister {
|
|
12
12
|
email: string;
|
|
@@ -22,38 +22,102 @@ interface UpdatePasswordForm {
|
|
|
22
22
|
new_password: string;
|
|
23
23
|
confirmNewPassword: string;
|
|
24
24
|
}
|
|
25
|
-
interface
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
interface ReactiveFactory {
|
|
26
|
+
<T>(initial: T): {
|
|
27
|
+
value: T;
|
|
28
|
+
set: (newValue: T) => void;
|
|
29
|
+
};
|
|
28
30
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
interface Token {
|
|
32
|
+
access_token: string;
|
|
33
|
+
}
|
|
34
|
+
interface PasswordRecovery {
|
|
35
|
+
email: string;
|
|
36
|
+
}
|
|
37
|
+
interface NewPassword {
|
|
33
38
|
new_password: string;
|
|
34
39
|
}
|
|
35
|
-
|
|
40
|
+
interface UserUpdate {
|
|
41
|
+
email?: string;
|
|
42
|
+
is_active?: boolean;
|
|
43
|
+
is_superuser?: boolean;
|
|
44
|
+
first_name?: string;
|
|
45
|
+
last_name?: string;
|
|
46
|
+
}
|
|
47
|
+
interface UserUpdateMe {
|
|
48
|
+
email?: string;
|
|
49
|
+
first_name?: string;
|
|
50
|
+
last_name?: string;
|
|
51
|
+
}
|
|
52
|
+
interface UpdatePassword {
|
|
53
|
+
current_password: string;
|
|
54
|
+
new_password: string;
|
|
55
|
+
}
|
|
56
|
+
interface UserCreate {
|
|
57
|
+
email: string;
|
|
58
|
+
password: string;
|
|
59
|
+
first_name?: string;
|
|
60
|
+
last_name?: string;
|
|
61
|
+
is_active?: boolean;
|
|
62
|
+
is_superuser?: boolean;
|
|
63
|
+
}
|
|
64
|
+
interface SanitizedUserOut {
|
|
65
|
+
email: string;
|
|
66
|
+
is_active?: boolean;
|
|
67
|
+
is_superuser?: boolean;
|
|
68
|
+
first_name?: string;
|
|
69
|
+
last_name?: string;
|
|
70
|
+
id: string;
|
|
71
|
+
}
|
|
72
|
+
interface SanitizedUserList {
|
|
73
|
+
data: SanitizedUserOut[];
|
|
74
|
+
count: number;
|
|
75
|
+
}
|
|
76
|
+
type LoginResponse = AxiosResponse<Token>;
|
|
77
|
+
type PasswordRecoveryResponse = AxiosResponse;
|
|
78
|
+
type ResetPasswordResponse = AxiosResponse;
|
|
79
|
+
type GetUserResponse = AxiosResponse<SanitizedUserOut>;
|
|
80
|
+
type UpdateUserResponse = AxiosResponse<SanitizedUserOut>;
|
|
81
|
+
type DeleteUserResponse = AxiosResponse;
|
|
82
|
+
type GetUsersResponse = AxiosResponse<SanitizedUserList>;
|
|
83
|
+
type CreateUserResponse = AxiosResponse<SanitizedUserOut>;
|
|
84
|
+
type GetMeResponse = AxiosResponse<SanitizedUserOut>;
|
|
85
|
+
type UpdateMeResponse = AxiosResponse<SanitizedUserOut>;
|
|
86
|
+
type UpdatePasswordResponse = AxiosResponse;
|
|
87
|
+
type SignupResponse = AxiosResponse<SanitizedUserOut>;
|
|
88
|
+
|
|
89
|
+
declare function login(username: string, password: string): Promise<LoginResponse>;
|
|
36
90
|
declare function logout(): void;
|
|
37
|
-
declare function passwordRecovery(email?: string): Promise<
|
|
38
|
-
declare function resetPassword(newPassword:
|
|
39
|
-
declare function getCurrentUser(): Promise<
|
|
40
|
-
declare function signup(user: NewUser): Promise<
|
|
41
|
-
declare function updatePassword(form: UpdatePasswordForm): Promise<
|
|
42
|
-
declare function updateUserProfile(user: Partial<User>): Promise<
|
|
43
|
-
declare function setUserStatus(userId: string, isActive: boolean): Promise<
|
|
44
|
-
declare function deleteUser(userId: string): Promise<
|
|
91
|
+
declare function passwordRecovery(email?: string): Promise<PasswordRecoveryResponse>;
|
|
92
|
+
declare function resetPassword(newPassword: NewPassword['new_password']): Promise<ResetPasswordResponse>;
|
|
93
|
+
declare function getCurrentUser(): Promise<GetMeResponse>;
|
|
94
|
+
declare function signup(user: NewUser): Promise<SignupResponse>;
|
|
95
|
+
declare function updatePassword(form: UpdatePasswordForm): Promise<UpdatePasswordResponse>;
|
|
96
|
+
declare function updateUserProfile(user: Partial<User>): Promise<UpdateMeResponse>;
|
|
97
|
+
declare function setUserStatus(userId: string, isActive: boolean): Promise<UpdateUserResponse>;
|
|
98
|
+
declare function deleteUser(userId: string): Promise<DeleteUserResponse>;
|
|
99
|
+
declare function getUsers(limit?: number, skip?: number): Promise<GetUsersResponse>;
|
|
100
|
+
declare function createUser(user: UserCreate): Promise<CreateUserResponse>;
|
|
101
|
+
declare function getUser(userId: string): Promise<GetUserResponse>;
|
|
45
102
|
|
|
46
|
-
declare function initAuth({ axios, errorHandler, reactive }?: {
|
|
103
|
+
declare function initAuth({ axios, errorHandler, reactive, baseURL }?: {
|
|
47
104
|
axios?: AxiosInstance;
|
|
48
105
|
errorHandler?: (error: any) => void;
|
|
49
106
|
reactive?: ReactiveFactory;
|
|
107
|
+
baseURL?: string;
|
|
50
108
|
}): {
|
|
51
109
|
install(app: any): void;
|
|
52
110
|
useAuth: typeof useAuth;
|
|
53
111
|
};
|
|
54
112
|
declare function useAuth(): {
|
|
55
|
-
currentUser:
|
|
56
|
-
|
|
113
|
+
currentUser: {
|
|
114
|
+
value: User;
|
|
115
|
+
set: (newValue: User) => void;
|
|
116
|
+
};
|
|
117
|
+
passwordForm: {
|
|
118
|
+
value: UpdatePasswordForm;
|
|
119
|
+
set: (newValue: UpdatePasswordForm) => void;
|
|
120
|
+
};
|
|
57
121
|
getFullName: () => string;
|
|
58
122
|
getIsLoggedIn: () => boolean;
|
|
59
123
|
logout: () => Promise<void>;
|
|
@@ -71,4 +135,4 @@ declare function useAuth(): {
|
|
|
71
135
|
deleteUser: (userId: string) => Promise<void>;
|
|
72
136
|
};
|
|
73
137
|
|
|
74
|
-
export { type
|
|
138
|
+
export { type CreateUserResponse, type DeleteUserResponse, type GetMeResponse, type GetUserResponse, type GetUsersResponse, type LoginResponse, type NewPassword, type NewUser, type PasswordRecovery, type PasswordRecoveryResponse, type ReactiveFactory, type ResetPasswordResponse, type SanitizedUserList, type SanitizedUserOut, type SignupResponse, type Token, type UpdateMeResponse, type UpdatePassword, type UpdatePasswordForm, type UpdatePasswordResponse, type UpdateUserResponse, type User, type UserCreate, type UserRegister, type UserUpdate, type UserUpdateMe, createUser, deleteUser, getCurrentUser, getUser, getUsers, initAuth, login, logout, passwordRecovery, resetPassword, setUserStatus, signup, updatePassword, updateUserProfile, useAuth };
|
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
|
-
import 'axios';
|
|
1
|
+
import axios from 'axios';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const api$1 = void 0;
|
|
4
4
|
function getApi() {
|
|
5
5
|
if (!api$1) {
|
|
6
|
-
throw new Error("API not initialized. Call
|
|
6
|
+
throw new Error("API not initialized. Call initAuth first.");
|
|
7
7
|
}
|
|
8
8
|
return api$1;
|
|
9
9
|
}
|
|
10
|
+
function createDefaultApi(baseURL) {
|
|
11
|
+
return axios.create({
|
|
12
|
+
baseURL,
|
|
13
|
+
headers: {
|
|
14
|
+
"Content-Type": "application/json"
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
10
18
|
|
|
11
19
|
const ax = getApi();
|
|
12
20
|
ax.interceptors.request.use((config) => {
|
|
@@ -27,22 +35,23 @@ async function login(username, password) {
|
|
|
27
35
|
password
|
|
28
36
|
});
|
|
29
37
|
localStorage.setItem("access_token", data.access_token);
|
|
38
|
+
return { data };
|
|
30
39
|
}
|
|
31
40
|
function logout() {
|
|
32
41
|
localStorage.removeItem("access_token");
|
|
33
42
|
window.location.reload();
|
|
34
43
|
}
|
|
35
44
|
async function passwordRecovery(email) {
|
|
36
|
-
return ax.post(
|
|
45
|
+
return ax.post("/auth/password-recovery", { email });
|
|
37
46
|
}
|
|
38
47
|
async function resetPassword(newPassword) {
|
|
39
48
|
return ax.post("/auth/reset-password", { new_password: newPassword });
|
|
40
49
|
}
|
|
41
50
|
async function getCurrentUser() {
|
|
42
|
-
return ax.get("/
|
|
51
|
+
return ax.get("/users/me");
|
|
43
52
|
}
|
|
44
53
|
async function signup(user) {
|
|
45
|
-
return ax.post("/
|
|
54
|
+
return ax.post("/users/signup", {
|
|
46
55
|
email: user.email.toLowerCase(),
|
|
47
56
|
password: user.password,
|
|
48
57
|
first_name: user.first_name,
|
|
@@ -50,24 +59,33 @@ async function signup(user) {
|
|
|
50
59
|
});
|
|
51
60
|
}
|
|
52
61
|
async function updatePassword(form) {
|
|
53
|
-
return ax.
|
|
62
|
+
return ax.patch("/users/me/password", {
|
|
54
63
|
current_password: form.current_password,
|
|
55
64
|
new_password: form.new_password
|
|
56
65
|
});
|
|
57
66
|
}
|
|
58
67
|
async function updateUserProfile(user) {
|
|
59
|
-
return ax.
|
|
68
|
+
return ax.patch("/users/me", user);
|
|
60
69
|
}
|
|
61
70
|
async function setUserStatus(userId, isActive) {
|
|
62
|
-
return ax.patch(`/
|
|
71
|
+
return ax.patch(`/users/${userId}`, { is_active: isActive });
|
|
63
72
|
}
|
|
64
73
|
async function deleteUser(userId) {
|
|
65
|
-
return ax.delete(`/
|
|
74
|
+
return ax.delete(`/users/${userId}`);
|
|
75
|
+
}
|
|
76
|
+
async function getUsers(limit = 100, skip) {
|
|
77
|
+
return ax.get("/users/", { params: { skip, limit } });
|
|
78
|
+
}
|
|
79
|
+
async function createUser(user) {
|
|
80
|
+
return ax.post("/users/", user);
|
|
81
|
+
}
|
|
82
|
+
async function getUser(userId) {
|
|
83
|
+
return ax.get(`/users/${userId}`);
|
|
66
84
|
}
|
|
67
85
|
|
|
68
|
-
let api
|
|
69
|
-
let onError
|
|
70
|
-
let createRef
|
|
86
|
+
let api;
|
|
87
|
+
let onError;
|
|
88
|
+
let createRef;
|
|
71
89
|
const defaultReactiveFactory = (initial) => {
|
|
72
90
|
let value = initial;
|
|
73
91
|
return {
|
|
@@ -95,10 +113,12 @@ function createVueReactiveFactory(app) {
|
|
|
95
113
|
function initAuth({
|
|
96
114
|
axios,
|
|
97
115
|
errorHandler,
|
|
98
|
-
reactive = defaultReactiveFactory
|
|
116
|
+
reactive = defaultReactiveFactory,
|
|
117
|
+
baseURL
|
|
99
118
|
} = {}) {
|
|
100
|
-
api = axios ||
|
|
101
|
-
|
|
119
|
+
api = axios || createDefaultApi(baseURL);
|
|
120
|
+
if (errorHandler)
|
|
121
|
+
onError = errorHandler;
|
|
102
122
|
createRef = reactive;
|
|
103
123
|
return {
|
|
104
124
|
install(app) {
|
|
@@ -253,4 +273,4 @@ function useAuth() {
|
|
|
253
273
|
};
|
|
254
274
|
}
|
|
255
275
|
|
|
256
|
-
export { deleteUser, getCurrentUser, initAuth, login, logout, passwordRecovery, resetPassword, setUserStatus, signup, updatePassword, updateUserProfile, useAuth };
|
|
276
|
+
export { createUser, deleteUser, getCurrentUser, getUser, getUsers, initAuth, login, logout, passwordRecovery, resetPassword, setUserStatus, signup, updatePassword, updateUserProfile, useAuth };
|
package/package.json
CHANGED
package/src/api/api.ts
CHANGED
|
@@ -1,24 +1,20 @@
|
|
|
1
1
|
import type { AxiosInstance } from 'axios'
|
|
2
2
|
import axios from 'axios'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export function initApi(axiosInstance?: AxiosInstance) {
|
|
7
|
-
if (axiosInstance) {
|
|
8
|
-
api = axiosInstance
|
|
9
|
-
} else {
|
|
10
|
-
api = axios.create({
|
|
11
|
-
baseURL: import.meta.env.VITE_API_URL || 'http://localhost:8000',
|
|
12
|
-
headers: {
|
|
13
|
-
'Content-Type': 'application/json',
|
|
14
|
-
},
|
|
15
|
-
})
|
|
16
|
-
}
|
|
17
|
-
}
|
|
4
|
+
const api: AxiosInstance | undefined = undefined
|
|
18
5
|
|
|
19
6
|
export function getApi(): AxiosInstance {
|
|
20
7
|
if (!api) {
|
|
21
|
-
throw new Error('API not initialized. Call
|
|
8
|
+
throw new Error('API not initialized. Call initAuth first.')
|
|
22
9
|
}
|
|
23
10
|
return api
|
|
24
11
|
}
|
|
12
|
+
|
|
13
|
+
export function createDefaultApi(baseURL?: string) {
|
|
14
|
+
return axios.create({
|
|
15
|
+
baseURL,
|
|
16
|
+
headers: {
|
|
17
|
+
'Content-Type': 'application/json',
|
|
18
|
+
},
|
|
19
|
+
})
|
|
20
|
+
}
|
package/src/api/auth.ts
CHANGED
|
@@ -1,12 +1,28 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { InternalAxiosRequestConfig } from 'axios'
|
|
2
|
+
import type {
|
|
3
|
+
User,
|
|
4
|
+
NewUser,
|
|
5
|
+
UpdatePasswordForm,
|
|
6
|
+
Token,
|
|
7
|
+
NewPassword,
|
|
8
|
+
UserCreate,
|
|
9
|
+
SanitizedUserOut,
|
|
10
|
+
SanitizedUserList,
|
|
11
|
+
LoginResponse,
|
|
12
|
+
PasswordRecoveryResponse,
|
|
13
|
+
ResetPasswordResponse,
|
|
14
|
+
GetUserResponse,
|
|
15
|
+
UpdateUserResponse,
|
|
16
|
+
DeleteUserResponse,
|
|
17
|
+
GetUsersResponse,
|
|
18
|
+
CreateUserResponse,
|
|
19
|
+
GetMeResponse,
|
|
20
|
+
UpdateMeResponse,
|
|
21
|
+
UpdatePasswordResponse,
|
|
22
|
+
SignupResponse
|
|
23
|
+
} from '../types'
|
|
3
24
|
import { getApi } from './api'
|
|
4
25
|
|
|
5
|
-
export interface NewPasswordPayload {
|
|
6
|
-
token: string
|
|
7
|
-
new_password: string
|
|
8
|
-
}
|
|
9
|
-
|
|
10
26
|
const ax = getApi()
|
|
11
27
|
|
|
12
28
|
ax.interceptors.request.use((config: InternalAxiosRequestConfig) => {
|
|
@@ -24,12 +40,13 @@ ax.interceptors.request.use((config: InternalAxiosRequestConfig) => {
|
|
|
24
40
|
return config
|
|
25
41
|
})
|
|
26
42
|
|
|
27
|
-
export async function login(username: string, password: string) {
|
|
28
|
-
const { data } = await ax.post('/auth/login', {
|
|
43
|
+
export async function login(username: string, password: string): Promise<LoginResponse> {
|
|
44
|
+
const { data } = await ax.post<Token>('/auth/login', {
|
|
29
45
|
username: username.toLowerCase(),
|
|
30
46
|
password,
|
|
31
47
|
})
|
|
32
48
|
localStorage.setItem('access_token', data.access_token)
|
|
49
|
+
return { data } as LoginResponse
|
|
33
50
|
}
|
|
34
51
|
|
|
35
52
|
export function logout() {
|
|
@@ -37,23 +54,21 @@ export function logout() {
|
|
|
37
54
|
window.location.reload()
|
|
38
55
|
}
|
|
39
56
|
|
|
40
|
-
export async function passwordRecovery(email?: string): Promise<
|
|
41
|
-
return ax.post(
|
|
57
|
+
export async function passwordRecovery(email?: string): Promise<PasswordRecoveryResponse> {
|
|
58
|
+
return ax.post('/auth/password-recovery', { email })
|
|
42
59
|
}
|
|
43
60
|
|
|
44
|
-
export async function resetPassword(
|
|
45
|
-
newPassword: NewPasswordPayload['new_password'],
|
|
46
|
-
): Promise<AxiosResponse> {
|
|
61
|
+
export async function resetPassword(newPassword: NewPassword['new_password']): Promise<ResetPasswordResponse> {
|
|
47
62
|
return ax.post('/auth/reset-password', { new_password: newPassword })
|
|
48
63
|
}
|
|
49
64
|
|
|
50
65
|
// User Management APIs
|
|
51
|
-
export async function getCurrentUser(): Promise<
|
|
52
|
-
return ax.get('/
|
|
66
|
+
export async function getCurrentUser(): Promise<GetMeResponse> {
|
|
67
|
+
return ax.get<SanitizedUserOut>('/users/me')
|
|
53
68
|
}
|
|
54
69
|
|
|
55
|
-
export async function signup(user: NewUser): Promise<
|
|
56
|
-
return ax.post('/
|
|
70
|
+
export async function signup(user: NewUser): Promise<SignupResponse> {
|
|
71
|
+
return ax.post<SanitizedUserOut>('/users/signup', {
|
|
57
72
|
email: user.email.toLowerCase(),
|
|
58
73
|
password: user.password,
|
|
59
74
|
first_name: user.first_name,
|
|
@@ -61,21 +76,33 @@ export async function signup(user: NewUser): Promise<AxiosResponse<User>> {
|
|
|
61
76
|
})
|
|
62
77
|
}
|
|
63
78
|
|
|
64
|
-
export async function updatePassword(form: UpdatePasswordForm): Promise<
|
|
65
|
-
return ax.
|
|
79
|
+
export async function updatePassword(form: UpdatePasswordForm): Promise<UpdatePasswordResponse> {
|
|
80
|
+
return ax.patch('/users/me/password', {
|
|
66
81
|
current_password: form.current_password,
|
|
67
82
|
new_password: form.new_password,
|
|
68
83
|
})
|
|
69
84
|
}
|
|
70
85
|
|
|
71
|
-
export async function updateUserProfile(user: Partial<User>): Promise<
|
|
72
|
-
return ax.
|
|
86
|
+
export async function updateUserProfile(user: Partial<User>): Promise<UpdateMeResponse> {
|
|
87
|
+
return ax.patch<SanitizedUserOut>('/users/me', user)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export async function setUserStatus(userId: string, isActive: boolean): Promise<UpdateUserResponse> {
|
|
91
|
+
return ax.patch<SanitizedUserOut>(`/users/${userId}`, { is_active: isActive })
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export async function deleteUser(userId: string): Promise<DeleteUserResponse> {
|
|
95
|
+
return ax.delete(`/users/${userId}`)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export async function getUsers(limit: number = 100, skip?: number): Promise<GetUsersResponse> {
|
|
99
|
+
return ax.get<SanitizedUserList>('/users/', { params: { skip, limit } })
|
|
73
100
|
}
|
|
74
101
|
|
|
75
|
-
export async function
|
|
76
|
-
return ax.
|
|
102
|
+
export async function createUser(user: UserCreate): Promise<CreateUserResponse> {
|
|
103
|
+
return ax.post<SanitizedUserOut>('/users/', user)
|
|
77
104
|
}
|
|
78
105
|
|
|
79
|
-
export async function
|
|
80
|
-
return ax.
|
|
106
|
+
export async function getUser(userId: string): Promise<GetUserResponse> {
|
|
107
|
+
return ax.get<SanitizedUserOut>(`/users/${userId}`)
|
|
81
108
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { AxiosInstance } from 'axios'
|
|
2
2
|
import type { User, NewUser, UpdatePasswordForm, ReactiveFactory } from '../types'
|
|
3
|
+
import { createDefaultApi } from '../api/api'
|
|
3
4
|
import * as authApi from '../api/auth'
|
|
4
5
|
|
|
5
|
-
let api: AxiosInstance
|
|
6
|
-
let onError: ((error: any) => void)
|
|
7
|
-
let createRef: ReactiveFactory
|
|
6
|
+
let api: AxiosInstance
|
|
7
|
+
let onError: ((error: any) => void)
|
|
8
|
+
let createRef: ReactiveFactory
|
|
8
9
|
|
|
9
10
|
const defaultReactiveFactory: ReactiveFactory = <T>(initial: T) => {
|
|
10
11
|
let value = initial
|
|
@@ -14,11 +15,6 @@ const defaultReactiveFactory: ReactiveFactory = <T>(initial: T) => {
|
|
|
14
15
|
}
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
// Vue plugin type
|
|
18
|
-
interface VuePlugin {
|
|
19
|
-
install: (app: any) => void
|
|
20
|
-
}
|
|
21
|
-
|
|
22
18
|
// Create Vue reactive factory
|
|
23
19
|
function createVueReactiveFactory(app: any): ReactiveFactory {
|
|
24
20
|
return <T>(initial: T) => {
|
|
@@ -34,14 +30,21 @@ function createVueReactiveFactory(app: any): ReactiveFactory {
|
|
|
34
30
|
export function initAuth({
|
|
35
31
|
axios,
|
|
36
32
|
errorHandler,
|
|
37
|
-
reactive = defaultReactiveFactory
|
|
33
|
+
reactive = defaultReactiveFactory,
|
|
34
|
+
baseURL
|
|
38
35
|
}: {
|
|
39
36
|
axios?: AxiosInstance
|
|
40
37
|
errorHandler?: (error: any) => void
|
|
41
38
|
reactive?: ReactiveFactory
|
|
39
|
+
baseURL?: string
|
|
42
40
|
} = {}) {
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
// Initialize API
|
|
42
|
+
api = axios || createDefaultApi(baseURL)
|
|
43
|
+
|
|
44
|
+
// Initialize error handler
|
|
45
|
+
if (errorHandler) onError = errorHandler
|
|
46
|
+
|
|
47
|
+
// Initialize reactive factory
|
|
45
48
|
createRef = reactive
|
|
46
49
|
|
|
47
50
|
// Return plugin interface
|
package/src/types.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import type { AxiosResponse } from 'axios'
|
|
2
|
+
|
|
1
3
|
export interface User {
|
|
2
4
|
id: string
|
|
3
5
|
email: string
|
|
4
|
-
first_name
|
|
5
|
-
last_name
|
|
6
|
-
is_superuser
|
|
7
|
-
is_active
|
|
6
|
+
first_name?: string
|
|
7
|
+
last_name?: string
|
|
8
|
+
is_superuser?: boolean
|
|
9
|
+
is_active?: boolean
|
|
8
10
|
}
|
|
9
11
|
|
|
10
12
|
export interface UserRegister {
|
|
@@ -24,9 +26,78 @@ export interface UpdatePasswordForm {
|
|
|
24
26
|
confirmNewPassword: string
|
|
25
27
|
}
|
|
26
28
|
|
|
27
|
-
export interface
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
export interface ReactiveFactory {
|
|
30
|
+
<T>(initial: T): {
|
|
31
|
+
value: T
|
|
32
|
+
set: (newValue: T) => void
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// API Response Types
|
|
37
|
+
export interface Token {
|
|
38
|
+
access_token: string
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface PasswordRecovery {
|
|
42
|
+
email: string
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface NewPassword {
|
|
46
|
+
new_password: string
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface UserUpdate {
|
|
50
|
+
email?: string
|
|
51
|
+
is_active?: boolean
|
|
52
|
+
is_superuser?: boolean
|
|
53
|
+
first_name?: string
|
|
54
|
+
last_name?: string
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface UserUpdateMe {
|
|
58
|
+
email?: string
|
|
59
|
+
first_name?: string
|
|
60
|
+
last_name?: string
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface UpdatePassword {
|
|
64
|
+
current_password: string
|
|
65
|
+
new_password: string
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface UserCreate {
|
|
69
|
+
email: string
|
|
70
|
+
password: string
|
|
71
|
+
first_name?: string
|
|
72
|
+
last_name?: string
|
|
73
|
+
is_active?: boolean
|
|
74
|
+
is_superuser?: boolean
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface SanitizedUserOut {
|
|
78
|
+
email: string
|
|
79
|
+
is_active?: boolean
|
|
80
|
+
is_superuser?: boolean
|
|
81
|
+
first_name?: string
|
|
82
|
+
last_name?: string
|
|
83
|
+
id: string
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface SanitizedUserList {
|
|
87
|
+
data: SanitizedUserOut[]
|
|
88
|
+
count: number
|
|
30
89
|
}
|
|
31
90
|
|
|
32
|
-
|
|
91
|
+
// API Response Types
|
|
92
|
+
export type LoginResponse = AxiosResponse<Token>
|
|
93
|
+
export type PasswordRecoveryResponse = AxiosResponse
|
|
94
|
+
export type ResetPasswordResponse = AxiosResponse
|
|
95
|
+
export type GetUserResponse = AxiosResponse<SanitizedUserOut>
|
|
96
|
+
export type UpdateUserResponse = AxiosResponse<SanitizedUserOut>
|
|
97
|
+
export type DeleteUserResponse = AxiosResponse
|
|
98
|
+
export type GetUsersResponse = AxiosResponse<SanitizedUserList>
|
|
99
|
+
export type CreateUserResponse = AxiosResponse<SanitizedUserOut>
|
|
100
|
+
export type GetMeResponse = AxiosResponse<SanitizedUserOut>
|
|
101
|
+
export type UpdateMeResponse = AxiosResponse<SanitizedUserOut>
|
|
102
|
+
export type UpdatePasswordResponse = AxiosResponse
|
|
103
|
+
export type SignupResponse = AxiosResponse<SanitizedUserOut>
|