Class AuthController
java.lang.Object
com.mt.ecommerce.product.controller.AuthController
Controller for handling authentication and user management.
Provides endpoints for user registration, vendor registration, and token generation.
-
Constructor Summary
ConstructorsConstructorDescriptionAuthController
(UserInfoService service, JwtService jwtService, org.springframework.security.authentication.AuthenticationManager authenticationManager) -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<?>
addNewUser
(UserInfo userInfo) Endpoint to register a new user.org.springframework.http.ResponseEntity<?>
Endpoint to register a new vendor user along with their store information.org.springframework.http.ResponseEntity<?>
authenticateAndGetToken
(AuthRequest authRequest) Endpoint to authenticate a user and generate a JWT token.org.springframework.http.ResponseEntity<?>
authenticateAndGetTokenForVendor
(AuthRequest authRequest) Endpoint to authenticate a vendor user and generate a JWT token.
-
Constructor Details
-
AuthController
public AuthController(UserInfoService service, JwtService jwtService, org.springframework.security.authentication.AuthenticationManager authenticationManager)
-
-
Method Details
-
addNewUser
@PostMapping(value="/user", consumes="application/json") public org.springframework.http.ResponseEntity<?> addNewUser(@RequestBody UserInfo userInfo) Endpoint to register a new user. Accepts a UserInfo object in the request body and returns the created user or an error message.- Parameters:
userInfo
- the user information to register- Returns:
- ResponseEntity with the created user or an error message
-
addVendor
@PostMapping(value="/user/vendor", consumes="application/json", produces={"application/json","text/plain"}) public org.springframework.http.ResponseEntity<?> addVendor(@RequestBody Store store) Endpoint to register a new vendor user along with their store information. Accepts a Store object in the request body and returns the created store or an error message.- Parameters:
store
- the store information along with user details to register- Returns:
- ResponseEntity with the created store or an error message
-
authenticateAndGetToken
@PostMapping("/token") public org.springframework.http.ResponseEntity<?> authenticateAndGetToken(@RequestBody AuthRequest authRequest) Endpoint to authenticate a user and generate a JWT token. Accepts an AuthRequest object in the request body and returns a UserInfoBO with the token or an error message.- Parameters:
authRequest
- the authentication request containing username and password- Returns:
- ResponseEntity with UserInfoBO containing the token or an error message
-
authenticateAndGetTokenForVendor
@PostMapping(value="/token/vendor", produces={"application/json","text/plain"}) public org.springframework.http.ResponseEntity<?> authenticateAndGetTokenForVendor(@RequestBody AuthRequest authRequest) Endpoint to authenticate a vendor user and generate a JWT token. Accepts an AuthRequest object in the request body and returns a Store with the token or an error message.- Parameters:
authRequest
- the authentication request containing username and password- Returns:
- ResponseEntity with Store containing the token or an error message
-