Various fixes + refacto

This commit is contained in:
emeric
2020-07-05 15:15:51 +02:00
parent c67e54aead
commit 50b0fd1cb8
21 changed files with 390 additions and 196 deletions
+7 -2
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2013 Emeric Poupon
auth_mode(C) 2013 Emeric Poupon
*
* This file is part of LMS.
*
@@ -40,7 +40,7 @@
namespace Database {
#define LMS_DATABASE_VERSION 24
#define LMS_DATABASE_VERSION 25
using Version = std::size_t;
@@ -267,6 +267,11 @@ CREATE TABLE "user_backup" (
// Just increment the scan version of the settings to make the next scheduled scan rescan everything
ScanSettings::get(*this).modify()->incScanVersion();
}
else if (version == 24)
{
// User's AuthMode
_session.execute("ALTER TABLE user ADD auth_mode INTEGER NOT NULL DEFAULT(" + std::to_string(static_cast<int>(User::defaultAuthMode)) + ")");
}
else
{
LMS_LOG(DB, ERROR) << "Database version " << version << " cannot be handled using migration";
+3 -5
View File
@@ -70,10 +70,8 @@ AuthToken::getByValue(Session& session, const std::string& value)
static const std::string playedListName {"__played_tracks__"};
static const std::string queuedListName {"__queued_tracks__"};
User::User(const std::string& loginName, const PasswordHash& passwordHash)
User::User(const std::string& loginName)
: _loginName {loginName}
, _passwordSalt {passwordHash.salt}
, _passwordHash {passwordHash.hash}
{
}
@@ -96,11 +94,11 @@ User::getDemo(Session& session)
}
User::pointer
User::create(Session& session, const std::string& loginName, const PasswordHash& passwordHash)
User::create(Session& session, const std::string& loginName)
{
session.checkUniqueLocked();
User::pointer user {session.getDboSession().add(std::make_unique<User>(loginName, passwordHash))};
User::pointer user {session.getDboSession().add(std::make_unique<User>(loginName))};
TrackList::create(session, playedListName, TrackList::Type::Internal, false, user);
TrackList::create(session, queuedListName, TrackList::Type::Internal, false, user);