blob: e8c8b7f5935f65ea4b7bb882fa4fe81c6c34cf77 [file] [log] [blame]
Joseph Reynolds8fd315a2019-09-12 12:02:33 -05001#pragma once
2
3#include "crow/http_response.h"
4
5namespace crow
6{
7namespace msg
8{
9const std::string notFoundMsg = "404 Not Found";
10const std::string badReqMsg = "400 Bad Request";
11const std::string methodNotAllowedMsg = "405 Method Not Allowed";
12const std::string forbiddenMsg = "403 Forbidden";
13const std::string methodFailedMsg = "500 Method Call Failed";
14const std::string methodOutputFailedMsg = "500 Method Output Error";
15const std::string unAuthMsg = "401 Unauthorized"; // Unauthenticated
16
17const std::string notFoundDesc =
18 "org.freedesktop.DBus.Error.FileNotFound: path or object not found";
19const std::string propNotFoundDesc = "The specified property cannot be found";
20const std::string noJsonDesc = "No JSON object could be decoded";
21const std::string methodNotFoundDesc = "The specified method cannot be found";
22const std::string methodNotAllowedDesc = "Method not allowed";
23const std::string forbiddenPropDesc =
24 "The specified property cannot be created";
25const std::string forbiddenResDesc = "The specified resource cannot be created";
26const std::string unAuthDesc = "The authentication could not be applied";
27const std::string forbiddenURIDesc = "The session is not authorized to access URI: ";
28
29} // namespace msg
30
31inline void setErrorResponse(crow::Response &res,
32 boost::beast::http::status result,
33 const std::string &desc, const std::string &msg)
34{
35 res.result(result);
36 res.jsonValue = {{"data", {{"description", desc}}},
37 {"message", msg},
38 {"status", "error"}};
39}
40
41inline void setPasswordChangeRequired(crow::Response &res,
42 const std::string &username)
43{
44 res.jsonValue["extendedMessage"] =
45 "The password for this account must be changed. PATCH the 'Password' "
46 "property for the account under URI: "
47 "/redfish/v1/AccountService/Accounts/" +
48 username;
49}
50
51} // namespace crow