Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @POST
- @Path("/loginR")
- @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
- @Produces(MediaType.APPLICATION_JSON)
- public Response loginR(@FormParam("user") String user, @FormParam("pass") String pass) throws SQLException, URISyntaxException {
- //System.out.println("hola");
- db.conn conexion = new db.conn();
- String username = user;
- String password = pass;
- String token = Security.login(username, password, conexion.getConn());
- System.out.println(token);
- boolean valid = Security.validate(token, "menu", conexion.getConn());
- if (!valid)
- return Response.status(Response.Status.UNAUTHORIZED).build();
- Map<String, Object> res = new HashMap<>();
- res.put("token", token);
- UriBuilder var = uriInfo.getBaseUriBuilder();
- var.path("../rlogin.html");
- if (token == null){
- token = "";
- }
- var.queryParam("token", token);
- URI uri = var.build();
- return Response.seeOther(uri).build();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement