refactor
Some checks reported errors
BlockStorage/repertory/pipeline/head Something is wrong with the build of this commit
Some checks reported errors
BlockStorage/repertory/pipeline/head Something is wrong with the build of this commit
This commit is contained in:
parent
e8118bac89
commit
0e21d93bb3
@ -85,19 +85,21 @@ auto handlers::check_authorization(const httplib::Request &req) -> bool {
|
||||
|
||||
auto authorization = req.get_header_value("Authorization");
|
||||
if (authorization.empty()) {
|
||||
utils::error::raise_error(function_name, "Authorization header is not set");
|
||||
utils::error::raise_error(function_name,
|
||||
"'Authorization' header is not set");
|
||||
return false;
|
||||
}
|
||||
|
||||
auto auth_parts = utils::string::split(authorization, ' ', true);
|
||||
if (auth_parts.empty()) {
|
||||
utils::error::raise_error(function_name, "Authorization header is empty");
|
||||
utils::error::raise_error(function_name, "'Authorization' header is empty");
|
||||
return false;
|
||||
}
|
||||
|
||||
auto auth_type = auth_parts[0U];
|
||||
if (auth_type != "Basic") {
|
||||
utils::error::raise_error(function_name, "Authorization is not Basic");
|
||||
utils::error::raise_error(function_name,
|
||||
"authorization type is not 'Basic'");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -106,7 +108,7 @@ auto handlers::check_authorization(const httplib::Request &req) -> bool {
|
||||
|
||||
auto auth = utils::string::split(auth_str, ':', false);
|
||||
if (auth.size() < 2U) {
|
||||
utils::error::raise_error(function_name, "Authorization is not valid");
|
||||
utils::error::raise_error(function_name, "authorization data is not valid");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -115,7 +117,7 @@ auto handlers::check_authorization(const httplib::Request &req) -> bool {
|
||||
|
||||
auto pwd = utils::string::join(auth, ':');
|
||||
if ((user != config_->get_api_user()) || (pwd != config_->get_api_auth())) {
|
||||
utils::error::raise_error(function_name, "Authorization failed");
|
||||
utils::error::raise_error(function_name, "authorization failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user