added: flag has_pass to User structure
if false that means the user has not set a password yet (this can be used by a plugins to create a new account without a password set) in order to login the user first has to set a new password (this can be done from a some kind of activation link send via email etc) git-svn-id: svn://ttmath.org/publicrep/winix/trunk@954 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
14
db/db.cpp
14
db/db.cpp
@@ -27,7 +27,7 @@ bool Db::GetUserPass(const std::wstring & login, long & user_id, UserPass & up)
|
||||
try
|
||||
{
|
||||
query.Clear();
|
||||
query << R("select id, password, pass_encrypted, pass_type, pass_hash_salted from core.user where login=")
|
||||
query << R("select id, has_pass, password, pass_encrypted, pass_type, pass_hash_salted from core.user where login=")
|
||||
<< login
|
||||
<< R(";");
|
||||
|
||||
@@ -46,6 +46,7 @@ bool Db::GetUserPass(const std::wstring & login, long & user_id, UserPass & up)
|
||||
}
|
||||
|
||||
int cuser_id = AssertColumn(r, "id");
|
||||
int chas_pass = AssertColumn(r, "has_pass");
|
||||
int cpass_type = AssertColumn(r, "pass_type");
|
||||
int csalted = AssertColumn(r, "pass_hash_salted");
|
||||
int cpassword = AssertColumn(r, "password");
|
||||
@@ -53,6 +54,7 @@ bool Db::GetUserPass(const std::wstring & login, long & user_id, UserPass & up)
|
||||
|
||||
user_ok = true;
|
||||
user_id = AssertValueLong(r, 0, cuser_id);
|
||||
up.has_pass = AssertValueBool(r, 0, chas_pass);
|
||||
up.pass_type = AssertValueInt(r, 0, cpass_type);
|
||||
up.pass_hash_salted = AssertValueBool(r, 0, csalted);
|
||||
AssertValueWide(r, 0, cpassword, up.pass);
|
||||
@@ -79,9 +81,10 @@ Error Db::AddUser(User & user, const UserPass & up)
|
||||
try
|
||||
{
|
||||
query.Clear();
|
||||
query << R("insert into core.user (login, password, pass_encrypted, super_user, email,"
|
||||
query << R("insert into core.user (login, has_pass, password, pass_encrypted, super_user, email,"
|
||||
"notify, pass_type, pass_hash_salted, env, aenv, status, locale_id, time_zone_id) values (")
|
||||
<< user.name;
|
||||
<< user.name
|
||||
<< up.has_pass;
|
||||
|
||||
// for safety we put up.pass only if there is not an encrypted version
|
||||
// someone could have forgotten to clear up.pass
|
||||
@@ -125,8 +128,9 @@ return status;
|
||||
Error Db::ChangeUserPass(long user_id, const UserPass & up)
|
||||
{
|
||||
query.Clear();
|
||||
query << R("update core.user set(password, pass_encrypted,"
|
||||
"pass_type, pass_hash_salted) = (");
|
||||
query << R("update core.user set(has_pass, password, pass_encrypted,"
|
||||
"pass_type, pass_hash_salted) = (")
|
||||
<< up.has_pass;
|
||||
|
||||
// for safety
|
||||
if( up.pass_encrypted.empty() )
|
||||
|
Reference in New Issue
Block a user