mirror of
https://github.com/mumble-voip/mumble.git
synced 2025-10-26 11:19:16 +00:00
Create SU account if it doesn't exist yet when setting password
This commit is contained in:
parent
d723a632ff
commit
8776329c67
@ -984,10 +984,22 @@ void ServerDB::setSUPW(int srvnum, const QString &pw) {
|
||||
TransactionHolder th;
|
||||
|
||||
QCryptographicHash hash(QCryptographicHash::Sha1);
|
||||
|
||||
hash.addData(pw.toUtf8());
|
||||
|
||||
QSqlQuery &query = *th.qsqQuery;
|
||||
|
||||
SQLPREP("SELECT `user_id` FROM `%1users` WHERE `server_id` = ? AND `user_id` = ?");
|
||||
query.addBindValue(srvnum);
|
||||
query.addBindValue(0);
|
||||
SQLEXEC();
|
||||
if (! query.next()) {
|
||||
SQLPREP("INSERT INTO `%1users` (`server_id`, `user_id`, `name`) VALUES (?, ?, ?)");
|
||||
query.addBindValue(srvnum);
|
||||
query.addBindValue(0);
|
||||
query.addBindValue(QLatin1String("SuperUser"));
|
||||
SQLEXEC();
|
||||
}
|
||||
|
||||
SQLPREP("UPDATE `%1users` SET `pw`=? WHERE `server_id` = ? AND `user_id`=?");
|
||||
query.addBindValue(QString::fromLatin1(hash.result().toHex()));
|
||||
query.addBindValue(srvnum);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user