add check email and pseudo
This commit is contained in:
parent
2d6953dc29
commit
a85e6b161e
@ -153,7 +153,7 @@ public class UsersRessources {
|
|||||||
public Response createUser(UsersEntity users) {
|
public Response createUser(UsersEntity users) {
|
||||||
Response.Status status = Response.Status.OK;
|
Response.Status status = Response.Status.OK;
|
||||||
UsersEntity usersPseudo = UsersEntity.findByPseudo(users.pseudo);
|
UsersEntity usersPseudo = UsersEntity.findByPseudo(users.pseudo);
|
||||||
UsersEntity usersEmail = UsersEntity.findByPseudo(users.email);
|
UsersEntity usersEmail = UsersEntity.findByEmail(users.email);
|
||||||
Boolean createUserBool = true;
|
Boolean createUserBool = true;
|
||||||
Boolean pseudoExist = false;
|
Boolean pseudoExist = false;
|
||||||
Boolean emailExist = false;
|
Boolean emailExist = false;
|
||||||
@ -167,7 +167,6 @@ public class UsersRessources {
|
|||||||
status = Response.Status.UNAUTHORIZED;
|
status = Response.Status.UNAUTHORIZED;
|
||||||
emailExist = true;
|
emailExist = true;
|
||||||
}
|
}
|
||||||
UserExist userExist = new UserExist(emailExist, pseudoExist);
|
|
||||||
if(createUserBool) {
|
if(createUserBool) {
|
||||||
UsersEntity usersNew = new UsersEntity();
|
UsersEntity usersNew = new UsersEntity();
|
||||||
usersNew.name = users.name;
|
usersNew.name = users.name;
|
||||||
@ -189,7 +188,7 @@ public class UsersRessources {
|
|||||||
status = Response.Status.NO_CONTENT;
|
status = Response.Status.NO_CONTENT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Response.status(status).entity(userExist).build();
|
return Response.status(status).entity(new UserExist(emailExist, pseudoExist)).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -203,13 +202,26 @@ public class UsersRessources {
|
|||||||
UUID kid = UUID.fromString(jwt.getClaim(Claims.kid));
|
UUID kid = UUID.fromString(jwt.getClaim(Claims.kid));
|
||||||
UsersEntity user = UsersEntity.findById(kid);
|
UsersEntity user = UsersEntity.findById(kid);
|
||||||
Response.Status status = getResponseCheck(ctx, userCookie, user);
|
Response.Status status = getResponseCheck(ctx, userCookie, user);
|
||||||
|
Boolean pseudoExist = false;
|
||||||
|
Boolean emailExist = false;
|
||||||
|
|
||||||
if (status.equals(Response.Status.OK)) {
|
if (status.equals(Response.Status.OK)) {
|
||||||
|
|
||||||
UsersEntity usersOrig = UsersEntity.findByPseudo(users.pseudo);
|
UsersEntity usersPseudo = UsersEntity.findByPseudo(users.pseudo);
|
||||||
if (usersOrig != null) {
|
UsersEntity usersEmail = UsersEntity.findByEmail(users.email);
|
||||||
|
Boolean createUserBool = true;
|
||||||
|
|
||||||
|
if (usersPseudo != null) {
|
||||||
|
createUserBool = false;
|
||||||
status = Response.Status.UNAUTHORIZED;
|
status = Response.Status.UNAUTHORIZED;
|
||||||
} else {
|
pseudoExist = true;
|
||||||
|
}
|
||||||
|
if(usersEmail != null){
|
||||||
|
createUserBool = false;
|
||||||
|
status = Response.Status.UNAUTHORIZED;
|
||||||
|
emailExist = true;
|
||||||
|
}
|
||||||
|
if(createUserBool) {
|
||||||
UsersEntity usersNew = new UsersEntity();
|
UsersEntity usersNew = new UsersEntity();
|
||||||
usersNew.name = users.name;
|
usersNew.name = users.name;
|
||||||
usersNew.pseudo = users.pseudo;
|
usersNew.pseudo = users.pseudo;
|
||||||
@ -231,7 +243,7 @@ public class UsersRessources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Response.status(status).build();
|
return Response.status(status).entity(new UserExist(emailExist, pseudoExist)).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete
|
// Delete
|
||||||
|
Loading…
x
Reference in New Issue
Block a user