save anon-user permissions from config in database on startup (interim solution)
This commit is contained in:
والد
7c435d61d4
کامیت
e87c3a0f4d
21
qswiki.cpp
21
qswiki.cpp
@ -85,12 +85,23 @@ int main(int argc, char **argv)
|
|||||||
logstream.open(config.logfile, std::fstream::out | std::fstream::app);
|
logstream.open(config.logfile, std::fstream::out | std::fstream::app);
|
||||||
Logger::setStream(&logstream);
|
Logger::setStream(&logstream);
|
||||||
|
|
||||||
User anon;
|
|
||||||
anon.login = config.anon_username;
|
|
||||||
anon.permissions = config.anon_permissions;
|
|
||||||
User::setAnon(anon);
|
|
||||||
|
|
||||||
auto database = createDatabase(config);
|
auto database = createDatabase(config);
|
||||||
|
|
||||||
|
// TODO: quite ugly, anon-handling must be rethought
|
||||||
|
auto userdao = database->createUserDao();
|
||||||
|
std::optional<User> anon = userdao->find(config.anon_username);
|
||||||
|
if(!anon)
|
||||||
|
{
|
||||||
|
throw std::runtime_error("No such anon user in database");
|
||||||
|
}
|
||||||
|
if(!anon->enabled)
|
||||||
|
{
|
||||||
|
throw std::runtime_error("Anon user cannot be enabled");
|
||||||
|
}
|
||||||
|
anon->permissions = config.anon_permissions;
|
||||||
|
userdao->save(anon.value());
|
||||||
|
User::setAnon(anon.value());
|
||||||
|
|
||||||
Template siteTemplate{config};
|
Template siteTemplate{config};
|
||||||
UrlProvider urlprovider{config};
|
UrlProvider urlprovider{config};
|
||||||
|
|
||||||
|
بارگذاری…
مرجع در شماره جدید
Block a user