A
A
Alexander Batula2019-08-30 19:40:16
Java
Alexander Batula, 2019-08-30 19:40:16

Is it correct to process the authorization code through a GET request?

Good afternoon, I'm new to this business, so please don't criticize, thanks.
I'm doing user registration through Spring Security after registration, the user receives an activation code, after which he will be redirected to the login page.
The question is, is it correct to catch a GET request via json and return json?. Is this the correct approach?
Is it correct to use @PathVariable in this case or should I use @RequestBody.
I will be glad to any answer.

@GetMapping(path = "/activate/{code}", consumes = "application/json", produces = "application/json")
  public EnrichedUserDto activate(@PathVariable String code) {
    EnrichedUserDto enrichedUserDto = new EnrichedUserDto();
    System.out.println(isActivated +  " " + "isActivate");

    if (isActivated) {
      enrichedUserDto.setHasError(false);
      enrichedUserDto.setMessage("User successfully activated");
    }else {
      enrichedUserDto.setHasError(true);
      enrichedUserDto.setMessage("Activation code is not found!");
    }
    return enrichedUserDto;
  }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
Chvalov, 2019-10-28
@Chvalov

Perhaps you wanted to say @RequestParaminstead @RequestBodybecause it @RequestBodydoes not apply to GET requests, but in your case only @PathVariable, because apart from the activation code, we don’t get any more parameters.
But in this case, only a GET request

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question