Skip to content

Commit 04f98a7

Browse files
committed
fix(http): upgrade auth and user http client
added rest client params to env
1 parent b2b6974 commit 04f98a7

8 files changed

+76
-97
lines changed

.env.example

+9
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,12 @@ GOOGLE_URL=https://www.googleapis.com/oauth2/v3/userinfo
6161

6262
# GITHUB
6363
GITHUB_URL=https://api.github.com/user
64+
65+
# REST CLIENT VSCODE [USER]
66+
REST_APPLE_TOKEN=
67+
REST_FACEBOOK_TOKEN=
68+
REST_GOOGLE_TOKEN=
69+
REST_GITHUB_TOKEN=
70+
REST_USER_LOGIN=[email protected]
71+
REST_USER_PASSWORD=123456
72+
REST_USER_ACCESS_TOKEN=

.env.test

+9
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,12 @@ GOOGLE_URL=https://www.googleapis.com/oauth2/v3/userinfo
6161

6262
# GITHUB
6363
GITHUB_URL=https://api.github.com/user
64+
65+
# REST CLIENT VSCODE [USER]
66+
REST_APPLE_TOKEN=
67+
REST_FACEBOOK_TOKEN=
68+
REST_GOOGLE_TOKEN=
69+
REST_GITHUB_TOKEN=
70+
REST_USER_LOGIN=[email protected]
71+
REST_USER_PASSWORD=123456
72+
REST_USER_ACCESS_TOKEN=

.vscode/settings.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"rest-client.environmentVariables": {
33
"local": {
4-
"host": "http://127.0.0.1:5858"
4+
"host": "http://127.0.0.1:5858",
5+
"apiUrl": "http://127.0.0.1:5858/api",
56
}
67
},
78
"rest-client.defaultHeaders": {

http/auth.http

+34-37
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,63 @@
1-
### LOGS USER INTO THE SYSTEM BY EMAIL AND PASSWORD
2-
POST {{host}}/api/auth/login
3-
Content-Type: application/json
1+
### LOGIN [USER]
2+
# @name loginUser
3+
POST {{apiUrl}}/v1/auth/login
44

55
{
6-
"email": "[email protected]",
7-
"password": "12345678"
6+
"email": "{{$dotenv REST_USER_LOGIN}}",
7+
"password": "{{$dotenv REST_USER_PASSWORD}}"
88
}
99

10+
### LOGOUT [USER]
11+
POST {{apiUrl}}/v1/auth/logout
12+
Authorization: Bearer {{loginUser.response.body.data.payload.accessToken}}
1013

11-
### LOGS OUT CURRENT LOGGED-IN USER SESSION
12-
POST {{host}}/api/auth/logout
13-
Authorization: Bearer {{accessToken}}
14-
Content-Type: application/json
14+
### LOGOUT [USER]
15+
POST {{apiUrl}}/v1/auth/logout
16+
Cookie: accessToken={{loginUser.response.body.data.payload.accessToken}}
1517

16-
### FORGOT PASSWORD
17-
POST {{host}}/api/auth/forgot-password
18-
Content-Type: application/json
18+
### REFRESH-TOKEN [USER]
19+
POST {{apiUrl}}/v1/auth/refresh-token
1920

2021
{
21-
"email": "{{email}}"
22+
"refreshToken": "{{loginUser.response.body.data.payload.refreshToken}}"
2223
}
2324

24-
### RESET PASSWORD
25-
POST {{host}}/api/auth/reset-password
26-
Content-Type: application/json
27-
28-
{
29-
"token": "{{passwordToken}}",
30-
"password": "{{newPassword}}"
31-
}
32-
33-
### REFRESH TOKEN
34-
POST {{host}}/api/auth/refresh-token
35-
Content-Type: application/json
25+
### LOGS USER INTO THE SYSTEM THROUGH A APPLE
26+
POST {{apiUrl}}/v1/auth/platform
3627

3728
{
38-
"refreshToken": "{{refreshToken}}"
29+
"token": "{{$dotenv REST_APPLE_TOKEN}}",
30+
"platform": "apple"
3931
}
4032

4133
### LOGS USER INTO THE SYSTEM THROUGH A FACEBOOK
42-
POST {{host}}/api/auth/platform
43-
Content-Type: application/json
34+
POST {{apiUrl}}/v1/auth/platform
4435

4536
{
46-
"token": "{{facebookToken}}",
37+
"token": "{{$dotenv REST_FACEBOOK_TOKEN}}",
4738
"platform": "facebook"
4839
}
4940

50-
### LOGS USER INTO THE SYSTEM THROUGH A APPLE
51-
POST {{host}}/api/auth/platform
52-
Content-Type: application/json
41+
42+
### LOGS USER INTO THE SYSTEM THROUGH A GOOGLE
43+
POST {{apiUrl}}/v1/auth/platform
5344

5445
{
55-
"token": "{{appleToken}}",
56-
"platform": "apple"
46+
"token": "{{$dotenv REST_GOOGLE_TOKEN}}",
47+
"platform": "github"
5748
}
5849

5950
### LOGS USER INTO THE SYSTEM THROUGH A GITHUB
60-
POST {{host}}/api/auth/platform
61-
Content-Type: application/json
51+
POST {{apiUrl}}/v1/auth/platform
6252

6353
{
64-
"token": "{{githubToken}}",
54+
"token": "{{$dotenv REST_GITHUB_TOKEN}}",
6555
"platform": "github"
6656
}
57+
58+
### FORGOT PASSWORD BY EMAIL
59+
POST {{apiUrl}}/v1/auth/password/email
60+
61+
{
62+
"email": "{{$dotenv REST_USER_LOGIN}}",
63+
}

http/config/.gitignore

-1
This file was deleted.

http/config/http-client.env.json

-8
This file was deleted.

http/config/http-client.private.env.example.json

-24
This file was deleted.

http/user.http

+22-26
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,39 @@
1-
### RETURN A CURRENT USER
2-
GET {{host}}/api/users/current
3-
Content-Type: application/json
1+
### RETURN A CURRENT USER [USER]
2+
GET {{apiUrl}}/v1/users/current
3+
Authorization: Bearer {{dotenv REST_USER_ACCESS_TOKEN}}
44

5-
### UPDATE A CURRENT USER
6-
PUT {{host}}/api/users/current
7-
Authorization: Bearer {{accessToken}}
8-
Content-Type: application/json
5+
### CREATE A USER [USER]
6+
POST {{host}}/api/users
97

108
{
9+
"email": "{{$dotenv REST_USER_LOGIN}}",
10+
"password": "{{$dotenv REST_USER_PASSWORD}}",
1111
"profile": {
12-
"firstName": "Dmitry",
13-
"lastName": "Neverovski"
12+
"firstName": "D.",
13+
"lastName": "N."
1414
}
1515
}
1616

17-
### CREATE A USER
18-
POST {{host}}/api/users
19-
Content-Type: application/json
17+
### UPDATE A CURRENT USER [USER]
18+
PUT {{apiUrl}}/v1/users/current
19+
Authorization: Bearer {{dotenv REST_USER_ACCESS_TOKEN}}
2020

2121
{
22-
"email": "{{email}}",
23-
"password": "{{password}}",
2422
"profile": {
25-
"firstName": "D.",
26-
"lastName": "N."
23+
"firstName": "Dmitry",
24+
"lastName": "Neverovski"
2725
}
2826
}
2927

30-
### CHANGE PASSWORD FOR A CURRENT USER
31-
POST {{host}}/api/users/current/change-password
32-
Authorization: Bearer {{accessToken}}
33-
Content-Type: application/json
28+
### CHANGE PASSWORD FOR A CURRENT USER [USER]
29+
POST {{apiUrl}}/v1/users/current/change-password
30+
Authorization: Bearer {{dotenv REST_USER_ACCESS_TOKEN}}
3431

3532
{
36-
"oldPassword": "{{password}}",
37-
"newPassword": "{{newPassword}}"
33+
"oldPassword": "{{$dotenv REST_USER_PASSWORD}}",
34+
"newPassword": "1234567"
3835
}
3936

40-
### DELETE A CURRENT USER
41-
DELETE {{host}}/api/users/current
42-
Authorization: Bearer {{accessToken}}
43-
Content-Type: application/json
37+
### DELETE A CURRENT USER [USER]
38+
DELETE {{apiUrl}}/v1/users/current
39+
Authorization: Bearer {{dotenv REST_USER_ACCESS_TOKEN}}

0 commit comments

Comments
 (0)