Skip to content

Latest commit

 

History

History
93 lines (82 loc) · 4.52 KB

File metadata and controls

93 lines (82 loc) · 4.52 KB

CRUD-REST-API

I have created this API to implement complete login and signup functionality with user authentication by using an access token. To avoid malicious email registration, I have implemented email verification by sending emails via Amazon Simple Email Service. I have deployed this web service on an Amazon EC2 instance which uses Amazon Linux 2023 as an OS. img

Tech Stack

Jax-rs, JPA, Jersey, Tomcat 10, HK2, Jsp, Java 17, Maven, AWS, Mysql

Note:- Here in the demonstration I have deployed the code on local only

Demonstration: How API works?

1. Registration/Create User

{
    "firstName" : "Sarfaraz",
    "lastName" : "Hussain",
    "email" : "call2me786@gmail.com",
    "password" : "password"
}
  • Http Response and we are creating userId unique as you can see in the response
{
    "email": "call2me786@gmail.com",
    "firstName": "Sarfaraz",
    "lastName": "Hussain",
    "userId": "XAmzmIfnvrTlfudz3LqigwjD0Yu5w3"
}
  • After getting the response an email has been sent to the registered email id we need to verify this otherwise our verification will not change in the database. You can see the emailVerificationStatus in the following DB SS. img
  • Go to registred email id inbox and verify the mail then emailVerificationStatus will change to 1. img img img

2. Login with user credentials that we have just created

  • First we need access token to login. URL to get access token is http://localhost:8080/mobile-app-ws/api/authentication . Following is the username and password in the form of JSON payload.This request will save half access token in the database and half will return as a response to the user and will store it in ios keychain if we are using this web service in ios application.
{
    "userName" : "call2me786@gmail.com",
    "userPassword" : "password"
}
  • Https response with access token
{
    "id": "XAmzmIfnvrTlfudz3LqigwjD0Yu5w3",
    "token": "9UFKFy5Wiw0W8nMB2cLuA="
}
  • Now we can login by using created id and access token. We will pass the created id as path parameter and token as the Bearer Token in postman header. img

3. Update user details

4. Get a unique user

5. Get list of users by Query Parameter

[
    {
        "email": "call2me786@gmail.com",
        "firstName": "Sultan",
        "href": "/users/user/XAmzmIfnvrTlfudz3LqigwjD0Yu5w3",
        "lastName": "Singh",
        "userId": "XAmzmIfnvrTlfudz3LqigwjD0Yu5w3"
    },
    {
        "email": "shiitian786@gmail.com",
        "firstName": "Sharukh",
        "href": "/users/user/5CWRDZtst0dshgnz1AvV12gqx72KBl",
        "lastName": "Khan",
        "userId": "5CWRDZtst0dshgnz1AvV12gqx72KBl"
    }
]

img