mirror of
https://github.com/sismics/docs.git
synced 2024-11-21 21:47:57 +01:00
remove check_username route
This commit is contained in:
parent
01d3e746d8
commit
ae2423b2e9
@ -30,8 +30,6 @@ import com.sismics.util.context.ThreadLocalContext;
|
||||
import com.sismics.util.filter.TokenBasedSecurityFilter;
|
||||
import com.sismics.util.totp.GoogleAuthenticator;
|
||||
import com.sismics.util.totp.GoogleAuthenticatorKey;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import jakarta.json.Json;
|
||||
import jakarta.json.JsonArrayBuilder;
|
||||
import jakarta.json.JsonObjectBuilder;
|
||||
@ -40,6 +38,8 @@ import jakarta.ws.rs.*;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.NewCookie;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@ -256,39 +256,6 @@ public class UserResource extends BaseResource {
|
||||
return Response.ok().entity(response.build()).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a username is available.
|
||||
* Search only on active accounts.
|
||||
*
|
||||
* @api {get} /user/check_username Check username availability
|
||||
* @apiName GetUserCheckUsername
|
||||
* @apiGroup User
|
||||
* @apiParam {String} username Username
|
||||
* @apiSuccess {String} status Status OK or KO
|
||||
* @apiPermission none
|
||||
* @apiVersion 1.5.0
|
||||
*
|
||||
* @param username Username to check
|
||||
* @return Response
|
||||
*/
|
||||
@GET
|
||||
@Path("check_username")
|
||||
public Response checkUsername(
|
||||
@QueryParam("username") String username) {
|
||||
UserDao userDao = new UserDao();
|
||||
User user = userDao.getActiveByUsername(username);
|
||||
|
||||
JsonObjectBuilder response = Json.createObjectBuilder();
|
||||
if (user != null) {
|
||||
response.add("status", "ko")
|
||||
.add("message", "Username already registered");
|
||||
} else {
|
||||
response.add("status", "ok");
|
||||
}
|
||||
|
||||
return Response.ok().entity(response.build()).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* This resource is used to authenticate the user and create a user session.
|
||||
* The "session" is only used to identify the user, no other data is stored in the session.
|
||||
|
@ -128,15 +128,6 @@ public class TestUserResource extends BaseJerseyTest {
|
||||
json = response.readEntity(JsonObject.class);
|
||||
Assert.assertEquals("AlreadyExistingUsername", json.getString("type"));
|
||||
|
||||
// Check if a username is free : OK
|
||||
target().path("/user/check_username").queryParam("username", "carol").request().get(JsonObject.class);
|
||||
|
||||
// Check if a username is free : KO
|
||||
response = target().path("/user/check_username").queryParam("username", "alice").request().get();
|
||||
Assert.assertEquals(Status.OK, Status.fromStatusCode(response.getStatus()));
|
||||
json = response.readEntity(JsonObject.class);
|
||||
Assert.assertEquals("ko", json.getString("status"));
|
||||
|
||||
// Login alice with extra whitespaces
|
||||
response = target().path("/user/login").request()
|
||||
.post(Entity.form(new Form()
|
||||
|
Loading…
Reference in New Issue
Block a user