Added notification for disabled gitlab accounts.

Closes #29
This commit is contained in:
Mutzi 2022-09-06 12:57:04 +02:00
parent 3c5b00ef14
commit 4a9bb7f4f3

View File

@ -91,6 +91,7 @@ namespace api {
cbk(drogon::HttpResponse::newRedirectionResponse(ss.str()));
}
std::string disabled_resp = "<!DOCTYPE html><html><h2>Your account is disabled, please contact an admin.&nbsp;<a href=\"/login\">Go to login page</a></h2></html>";
void auth::gitlab_callback(req_type, cbk_type cbk, std::string code) {
auto tokens = get_gitlab_tokens(code, false);
if (!tokens.has_value())
@ -123,6 +124,9 @@ namespace api {
db_user.setGitlabRt(tokens->rt);
user_mapper.update(db_user);
if (db::User_getEnumRole(db_user) == db::UserRole::DISABLED)
return cbk(drogon::HttpResponse::newFileResponse((unsigned char*)disabled_resp.data(), disabled_resp.size(), "", drogon::ContentType::CT_TEXT_HTML));
const std::string& token = get_token(db_user);
cbk(drogon::HttpResponse::newRedirectionResponse("/set_token?token="+token));
}