Advertisement
Guest User

Untitled

a guest
Dec 29th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.05 KB | None | 0 0
  1.     @POST
  2.     @Path("/loginR")
  3.     @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
  4.     @Produces(MediaType.APPLICATION_JSON)
  5.     public Response loginR(@FormParam("user") String user, @FormParam("pass") String pass) throws SQLException, URISyntaxException {
  6.         //System.out.println("hola");
  7.         db.conn conexion = new db.conn();
  8.         String username = user;
  9.         String password = pass;
  10.         String token = Security.login(username, password, conexion.getConn());
  11.         System.out.println(token);
  12.         boolean valid = Security.validate(token, "menu", conexion.getConn());
  13.         if (!valid)
  14.             return Response.status(Response.Status.UNAUTHORIZED).build();
  15.         Map<String, Object> res = new HashMap<>();
  16.         res.put("token", token);
  17.         UriBuilder var = uriInfo.getBaseUriBuilder();
  18.         var.path("../rlogin.html");
  19.         if (token == null){
  20.             token = "";
  21.         }
  22.         var.queryParam("token", token);
  23.         URI uri = var.build();
  24.         return Response.seeOther(uri).build();
  25.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement