@@ -86,7 +86,8 @@ Follow the steps below to run the application:
86
86
* (my mysql database is authentication_system , so create only database with any name as per your requirement)
87
87
* Run the application using Intellij IDE.
88
88
89
- * This is my application.properties
89
+ * This is my application.properties
90
+ ``` http
90
91
* #Database Configuration
91
92
* spring.datasource.url=jdbc:mysql://localhost:3306/authentication_system <---Add your database name only
92
93
@@ -107,7 +108,7 @@ spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect
107
108
app.jwt-secret=JWTSecretKey
108
109
app.jwt-expiration-milliseconds=604800000
109
110
110
-
111
+ ```
111
112
112
113
113
114
# Usage
@@ -121,16 +122,17 @@ You can interact with the API endpoints using Postman or any other API testing t
121
122
* Method POST: http://localhost:8080/api/auth/register
122
123
Select --> Body --> raw --> JSON
123
124
Request Body:
124
-
125
+ ``` http
125
126
* JSON Structure
126
127
{
127
128
"username": "woromedia_1",
128
129
"password": "password123",
129
130
"email": "woromedia_1@example.com"
130
131
}
132
+ ```
131
133
click on ---> Send
132
134
* Response: HTTP 200 OK with "User registered successfully" message.
133
- *
135
+
134
136
![ User_register] ( https://github.com/SDEParag/Java-backend-Spring-boot-MySQL-login-logout-Authentication-System/assets/137553676/9f503ac4-834d-409e-ad7c-01bcd9c40558 )
135
137
136
138
* Bad Credentials: If the provided username or email is already taken,
@@ -142,42 +144,47 @@ the endpoint returns HTTP 400 Bad Request with an appropriate error message.
142
144
143
145
144
146
* 2 User Login Endpoint:
147
+
145
148
URL:
146
149
* Method POST: http://localhost:8080/api/auth/login
147
150
Select --> Body --> raw --> JSON
148
151
Request Body:
152
+ ``` http
149
153
* JSON Structure
150
154
{
151
155
"usernameOrEmail": "woromediaintern_1",
152
156
"password": "password123"
153
157
}
154
-
158
+ ```
155
159
* Response: HTTP 200 OK with a JWT token in the response body.
156
160
157
161
![ login] ( https://github.com/SDEParag/Java-backend-Spring-boot-MySQL-login-logout-Authentication-System/assets/137553676/c17d8308-a24b-4d27-af94-39571bd7d8df )
158
162
159
163
* JWT token (On successful login):
164
+ ``` http
160
165
{
161
166
"token": "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJ3b3JvbWVkaWFfMUBleGFtcGxlLmNvb
162
167
SIsImlhdCI6MTY5MTcwOTA0NywiZXhwIjoxNjkyMzEzODQ3fQ.d4GRTnppSYzlONRFleCqRbRgi7WsJe_fxv6Ui
163
168
EOpfl9h5sr5FG5D3EQ9IdkKGNxZVKnNbKTU-hZi_bPtRMtafg",
164
169
"tokenType": "Bearer"
165
170
}
166
- }
167
-
171
+ ```
168
172
* Bad Credentials: If the provided username or email and password combination is invalid, the endpoint returns HTTP 401 Unauthorized with an error message.
169
173
170
174
![ wrong input password or username] ( https://github.com/SDEParag/Java-backend-Spring-boot-MySQL-login-logout-Authentication-System/assets/137553676/139656f1-a667-4ad8-8817-49c04fbe48ae )
171
175
172
- * 3 Admin Panel Endpoint:
173
176
177
+ * 3 Admin Panel Endpoint:
178
+ ``` http
174
179
URL:
175
180
* Method GET : http://localhost:8080/api/auth/admin
176
181
177
182
* Select --> Authorization --> Bearer token --> copy login token paste in Token like below,
178
- Token: [ eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJ3b3JvbWVkaWFfMUBleGFtcGxlLmNvb
179
- SIsImlhdCI6MTY5MTcwOTA0NywiZXhwIjoxNjkyMzEzODQ3fQ.d4GRTnppSYzlONRFleCqRbRgi7WsJe_fxv6Ui
180
- EOpfl9h5sr5FG5D3EQ9IdkKGNxZVKnNbKTU-hZi_bPtRMtafg ]
183
+
184
+ Token:
185
+ [eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJ3b3JvbWVkaWFfMUBleGFtcGxlLmNvbSIsImlhdCI6MTY5MTcwOTA0NywiZXhwI
186
+ joxNjkyMzEzODQ3fQ.d4GRTnppSYzlONRFleCqRbRgi7WsJe_fxv6UiEOpfl9h5sr5FG5D3EQ9IdkKGNxZVKnNbKTU-hZi_bPtRMtafg]
187
+ ```
181
188
182
189
Click on Send
183
190
* Response: HTTP 200 OK with "Admin Panel" message.
0 commit comments