meet-my-ride 1.0.4 → 1.0.5
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AxiosInstance } from "axios";
|
|
2
|
-
import { UserLogin,
|
|
2
|
+
import { UserLogin, UserRegister, User, UserUpdate, UserRefreshResponse, AuthResponse, UserRegisterResponse, VerifyEmailResponse } from "./user.types";
|
|
3
3
|
export declare class UserService {
|
|
4
4
|
private http;
|
|
5
5
|
private updateToken;
|
|
@@ -13,11 +13,11 @@ export declare class UserService {
|
|
|
13
13
|
/** DELETE /api/Users/{userId} */
|
|
14
14
|
delete(userId: string): Promise<void>;
|
|
15
15
|
/** POST /api/Users/register */
|
|
16
|
-
register(data: UserRegister): Promise<
|
|
16
|
+
register(data: UserRegister): Promise<UserRegisterResponse>;
|
|
17
17
|
/** POST /api/Users/login */
|
|
18
|
-
login(data: UserLogin): Promise<
|
|
18
|
+
login(data: UserLogin): Promise<AuthResponse>;
|
|
19
19
|
/** POST /api/Users/refresh */
|
|
20
20
|
refresh(refreshToken: string): Promise<UserRefreshResponse>;
|
|
21
21
|
/** POST /api/Users/verify-email */
|
|
22
|
-
verifyEmail(
|
|
22
|
+
verifyEmail(userId: string, token: string): Promise<VerifyEmailResponse>;
|
|
23
23
|
}
|
|
@@ -34,8 +34,9 @@ class UserService {
|
|
|
34
34
|
async login(data) {
|
|
35
35
|
const response = await this.http.post("/api/Users/login", data);
|
|
36
36
|
const resData = response.data;
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
// Only update token if it exists
|
|
38
|
+
if (resData.accessToken) {
|
|
39
|
+
this.updateToken(resData.accessToken);
|
|
39
40
|
}
|
|
40
41
|
return resData;
|
|
41
42
|
}
|
|
@@ -45,14 +46,18 @@ class UserService {
|
|
|
45
46
|
refreshToken
|
|
46
47
|
});
|
|
47
48
|
const resData = response.data;
|
|
48
|
-
if (resData.
|
|
49
|
-
this.updateToken(resData.
|
|
49
|
+
if (resData.accessToken) {
|
|
50
|
+
this.updateToken(resData.accessToken);
|
|
50
51
|
}
|
|
51
52
|
return resData;
|
|
52
53
|
}
|
|
53
54
|
/** POST /api/Users/verify-email */
|
|
54
|
-
async verifyEmail(
|
|
55
|
-
await this.http.post("/api/Users/
|
|
55
|
+
async verifyEmail(userId, token) {
|
|
56
|
+
const response = await this.http.post("/api/Users/verifyEmail", {
|
|
57
|
+
userId,
|
|
58
|
+
token
|
|
59
|
+
});
|
|
60
|
+
return response.data;
|
|
56
61
|
}
|
|
57
62
|
}
|
|
58
63
|
exports.UserService = UserService;
|
|
@@ -1,33 +1,47 @@
|
|
|
1
1
|
export interface User {
|
|
2
2
|
id: string;
|
|
3
3
|
email: string;
|
|
4
|
+
emailVerified?: string;
|
|
4
5
|
firstName: string;
|
|
5
6
|
lastName: string;
|
|
7
|
+
username: string;
|
|
6
8
|
}
|
|
7
9
|
export interface UserLogin {
|
|
8
10
|
email: string;
|
|
9
11
|
password: string;
|
|
10
12
|
}
|
|
11
|
-
export interface
|
|
12
|
-
|
|
13
|
+
export interface AuthResponse {
|
|
14
|
+
user: User;
|
|
15
|
+
accessToken?: string;
|
|
13
16
|
refreshToken?: string;
|
|
14
|
-
userId?: string;
|
|
15
|
-
expiresIn?: number;
|
|
16
17
|
}
|
|
17
18
|
export interface UserRegister {
|
|
18
19
|
email: string;
|
|
19
20
|
password: string;
|
|
20
21
|
firstName: string;
|
|
21
22
|
lastName: string;
|
|
23
|
+
username: string;
|
|
24
|
+
}
|
|
25
|
+
export interface UserRegisterResponse {
|
|
26
|
+
id: string;
|
|
27
|
+
username: string;
|
|
28
|
+
firstName: string;
|
|
29
|
+
lastName: string;
|
|
30
|
+
email: string;
|
|
22
31
|
}
|
|
23
32
|
export interface UserUpdate {
|
|
24
33
|
email?: string;
|
|
25
34
|
firstName?: string;
|
|
26
35
|
lastName?: string;
|
|
27
36
|
password?: string;
|
|
37
|
+
username?: string;
|
|
28
38
|
}
|
|
29
39
|
export interface UserRefreshResponse {
|
|
30
|
-
|
|
40
|
+
accessToken: string;
|
|
31
41
|
refreshToken?: string;
|
|
32
42
|
expiresIn?: number;
|
|
33
43
|
}
|
|
44
|
+
export interface VerifyEmailResponse {
|
|
45
|
+
message: string;
|
|
46
|
+
isVerified: boolean;
|
|
47
|
+
}
|
package/dist/users/user.types.js
CHANGED