https://github.com/prakhardoneria/mysql-authentication-system
https://github.com/prakhardoneria/mysql-authentication-system
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/prakhardoneria/mysql-authentication-system
- Owner: PrakharDoneria
- Created: 2024-08-03T13:32:08.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-03T13:41:28.000Z (about 1 year ago)
- Last Synced: 2025-04-06T07:34:08.531Z (6 months ago)
- Language: JavaScript
- Homepage:
- Size: 653 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Endpoint usage
### Register a New User
- **Endpoint:** `/register`
- **Method:** POST
- **Description:** Registers a new user with an email, username, and password.
- **Request Body:**```json
{
"email": "user@example.com",
"username": "your_username",
"password": "your_password"
}
```- **Sample Responses:**
- **Successful Registration:**
```json
{
"message": "User registered successfully!"
}
```- **Email or Username Already In Use:**
```json
{
"message": "Email or username already in use!"
}
```### Login
- **Endpoint:** `/login`
- **Method:** POST
- **Description:** Authenticates a user with either an email or username and password.
- **Request Body:**```json
{
"email": "user@example.com",
"username": "your_username",
"password": "your_password"
}
```- **Sample Responses:**
- **Successful Login:**
```json
{
"message": "Login successful!"
}
```- **User Not Found:**
```json
{
"message": "User not found!"
}
```- **Invalid Password:**
```json
{
"message": "Invalid password!"
}
```## Example Usage with `curl`
**Register:**
```sh
curl -X POST http://localhost:8000/register \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"username": "newuser",
"password": "newpassword"
}'
```**Login:**
```sh
curl -X POST http://localhost:8000/login \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"username": "newuser",
"password": "newpassword"
}'
```