https://github.com/mmallikarjun2312/authentication_api
User_login_signup_Authentication using NodeJS, Express JS, SQLite these api's perform various operations like verifying user credentials while login/signup after entering valid credentials it also encrypts password while signing up new user before storing in DB.
https://github.com/mmallikarjun2312/authentication_api
api authentication database expressjs javascript loginsignup nodejs sqlite3
Last synced: 3 months ago
JSON representation
User_login_signup_Authentication using NodeJS, Express JS, SQLite these api's perform various operations like verifying user credentials while login/signup after entering valid credentials it also encrypts password while signing up new user before storing in DB.
- Host: GitHub
- URL: https://github.com/mmallikarjun2312/authentication_api
- Owner: MMALLIKARJUN2312
- Created: 2024-04-18T09:36:39.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-18T09:40:32.000Z (about 2 years ago)
- Last Synced: 2025-01-16T13:48:47.740Z (over 1 year ago)
- Topics: api, authentication, database, expressjs, javascript, loginsignup, nodejs, sqlite3
- Language: JavaScript
- Homepage:
- Size: 91.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Authentication
Given an `app.js` file and a database file `userData.db` consisting of a table `user`.
Write APIs to perform operations on the table `user` containing the following columns,
**User Table**
| Column | Type |
| -------- | ------- |
| username | TEXT |
| name | TEXT |
| password | TEXT |
| gender | TEXT |
|location|TEXT|
### API 1
#### Path: `/register`
#### Method: `POST`
**Request**
```
{
"username": "adam_richard",
"name": "Adam Richard",
"password": "richard_567",
"gender": "male",
"location": "Detroit"
}
```
- **Scenario 1**
- **Description**:
If the username already exists
- **Response**
- **Status code**
```
400
```
- **Status text**
```
User already exists
```
- **Scenario 2**
- **Description**:
If the registrant provides a password with less than 5 characters
- **Response**
- **Status code**
```
400
```
- **Status text**
```
Password is too short
```
- **Scenario 3**
- **Description**:
Successful registration of the registrant
- **Response**
- **Status code**
```
200
```
- **Status text**
```
User created successfully
```
### API 2
#### Path: `/login`
#### Method: `POST`
**Request**
```
{
"username": "adam_richard",
"password": "richard_567"
}
```
- **Scenario 1**
- **Description**:
If an unregistered user tries to login
- **Response**
- **Status code**
```
400
```
- **Status text**
```
Invalid user
```
- **Scenario 2**
- **Description**:
If the user provides incorrect password
- **Response**
- **Status code**
```
400
```
- **Status text**
```
Invalid password
```
- **Scenario 3**
- **Description**:
Successful login of the user
- **Response**
- **Status code**
```
200
```
- **Status text**
```
Login success!
```
### API 3
#### Path: `/change-password`
#### Method: `PUT`
**Request**
```
{
"username": "adam_richard",
"oldPassword": "richard_567",
"newPassword": "richard@123"
}
```
- **Scenario 1**
- **Description**:
If the user provides incorrect current password
- **Response**
- **Status code**
```
400
```
- **Status text**
```
Invalid current password
```
- **Scenario 2**
- **Description**:
If the user provides new password with less than 5 characters
- **Response**
- **Status code**
```
400
```
- **Status text**
```
Password is too short
```
- **Scenario 3**
- **Description**:
Successful password update
- **Response**
- **Status code**
```
200
```
- **Status text**
```
Password updated
```
Use `npm install` to install the packages.
**Export the express instance using the default export syntax.**
**Use Common JS module syntax.**