From 4a9bb7f4f344d2cb5c3beac808ee84e02ca67ca1 Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 6 Sep 2022 12:57:04 +0200 Subject: [PATCH] Added notification for disabled gitlab accounts. Closes #29 --- backend/src/controllers/auth/auth_gitlab.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/src/controllers/auth/auth_gitlab.cpp b/backend/src/controllers/auth/auth_gitlab.cpp index 2af6d53..835eb16 100644 --- a/backend/src/controllers/auth/auth_gitlab.cpp +++ b/backend/src/controllers/auth/auth_gitlab.cpp @@ -91,6 +91,7 @@ namespace api { cbk(drogon::HttpResponse::newRedirectionResponse(ss.str())); } + std::string disabled_resp = "

Your account is disabled, please contact an admin. Go to login page

"; 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)); }