@POST
    @Timed
    @Path("login")
    @Consumes("application/x-www-form-urlencoded")
    @Produces({"application/json"})
    public Response login(@CookieParam("authUser") String existingUserCookie, @FormParam("destination") String destination, @FormParam("username") String username, @FormParam("password") String password) {
        try {
            if (!Strings.isNullOrEmpty(username) && !Strings.isNullOrEmpty(password)) {
                UserAccount user = dataStore.getUser(username);
                if (user != null && user.hashedPassword != null && user.hashedPassword.equalsIgnoreCase(UserAccount.hashPassword(password, salt))) {
                    try {
                        //Create a new token for this session
                        String token = UUID.randomUUID().toString();

                        //Save a new UserToken for this session
                        UserToken userToken = new UserToken();
                        userToken.token = token;
                        userToken.userAccount = user;
                        userToken.created = System.currentTimeMillis();
                        userToken = dataStore.newUserToken(userToken);

                        return Response.seeOther(((!Strings.isNullOrEmpty(destination))?new URI(destination):LANDING_HTML)).cacheControl(NO_CACHE_CONTROL).cookie(newUserCookie(userToken.token)).build();
                    } catch(Exception e) {
                        e.printStackTrace();
                        //fall through to fail code
                    }
                }
            }

            //If login fails, log them out just in case were already logged in previously
            logoutUserToken(existingUserCookie);
            return Response.seeOther(new URI(serviceBaseURL + "login.html?" + "destination=" + ((!Strings.isNullOrEmpty(destination))?URLEncoder.encode(destination, "UTF-8"):"") +
                "&message="+URLEncoder.encode("Login unsuccessful", "UTF-8") )).cacheControl(NO_CACHE_CONTROL).cookie(newEmptyExpiredCookie()).build();

        } catch (Exception e) {
            L.error("Unable to login user: " + username, e);
        }

        throw new WebApplicationException(Response.serverError().cacheControl(NO_CACHE_CONTROL).cookie(newEmptyExpiredCookie()).build());
    }