Exemple #1
0
	void auth_token(Mongoose::Request &request, Mongoose::StreamResponse &response) {
		if (password.empty() || password != request.get("password")) {
			response.setCode(HTTP_FORBIDDEN);
			response << "403 Invalid password";
		} else {
			std::string token = tokens.generate();
			response.setHeader("__TOKEN", token);
			response << "{ \"status\" : \"ok\", \"auth token\": \"" << token << "\" }";
		}
	}
Exemple #2
0
	void redirect_index(Mongoose::Request&, Mongoose::StreamResponse &response) {
		response.setCode(302);
		response.setHeader("Location", "/index.html");
	}
Exemple #3
0
	void auth_logout(Mongoose::Request &request, Mongoose::StreamResponse &response) {
		std::string token = request.get("token");
		tokens.revoke(token);
		response.setHeader("__TOKEN", "");
		response << "{ \"status\" : \"ok\", \"auth token\": \"\" }";
	}