Skip to content

A REST-API handling complete login & signup functionality with email verification and also implementing the access token functionality.

Notifications You must be signed in to change notification settings

Sarfaraz-Hussain/SignIn-SignUp-API-Using-JakartaEE

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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" : "[email protected]",
    "password" : "password"
}
  • Http Response and we are creating userId unique as you can see in the response
{
    "email": "[email protected]",
    "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 https://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" : "[email protected]",
    "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": "[email protected]",
        "firstName": "Sultan",
        "href": "/users/user/XAmzmIfnvrTlfudz3LqigwjD0Yu5w3",
        "lastName": "Singh",
        "userId": "XAmzmIfnvrTlfudz3LqigwjD0Yu5w3"
    },
    {
        "email": "[email protected]",
        "firstName": "Sharukh",
        "href": "/users/user/5CWRDZtst0dshgnz1AvV12gqx72KBl",
        "lastName": "Khan",
        "userId": "5CWRDZtst0dshgnz1AvV12gqx72KBl"
    }
]

img

About

A REST-API handling complete login & signup functionality with email verification and also implementing the access token functionality.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published