Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Datovka projects
mobile Datovka
Commits
9b9ca650
Commit
9b9ca650
authored
Oct 23, 2018
by
Martin Straka
Committed by
Karel Slaný
Nov 15, 2018
Browse files
Removed new user name if an error
parent
798f79ce
Changes
3
Hide whitespace changes
Inline
Side-by-side
qml/pages/PageSettingsAccount.qml
View file @
9b9ca650
...
...
@@ -98,12 +98,12 @@ Item {
}
else
{
// Change account user name.
if
(
userNameTextField
.
text
.
toString
()
!==
oldUserName
)
{
if
(
accounts
.
c
re
ateAccount
(
accountModel
,
sLoginMethod
,
if
(
accounts
.
p
re
pareChangeUserName
(
accountModel
,
sLoginMethod
,
accountNameTextField
.
text
.
toString
(),
userNameTextField
.
text
.
toString
(),
passwordTextField
.
text
.
toString
(),
testAccount
.
checked
,
rememberPassword
.
checked
,
useLS
.
checked
,
certPathLabelId
.
text
.
toString
()))
{
useLS
.
checked
,
certPathLabelId
.
text
.
toString
()
,
oldUserName
))
{
isds
.
doIsdsAction
(
"
changeUserName
"
,
userNameTextField
.
text
.
toString
())
}
}
else
{
...
...
src/accounts.cpp
View file @
9b9ca650
...
...
@@ -201,7 +201,7 @@ fail:
}
bool
Accounts
::
updateAccount
(
const
QVariant
&
acntModelVariant
,
const
QString
&
loginMetod
,
const
QString
&
acntName
,
const
QString
&
newU
serName
,
const
QString
&
loginMetod
,
const
QString
&
acntName
,
const
QString
&
u
serName
,
const
QString
&
pwd
,
bool
isTestAccount
,
bool
rememberPwd
,
bool
storeToDisk
,
const
QString
&
certPath
)
{
...
...
@@ -231,8 +231,6 @@ bool Accounts::updateAccount(const QVariant &acntModelVariant,
return
false
;
}
QString
userName
=
newUserName
.
trimmed
();
if
(
!
GlobInstcs
::
acntMapPtr
->
contains
(
userName
))
{
return
false
;
}
...
...
@@ -420,11 +418,11 @@ void Accounts::loadModelCounters(AccountListModel *accountModel)
}
}
bool
Accounts
::
changeAccountUserName
(
const
QVariant
&
acntModelVariant
,
const
QString
&
acntName
,
const
QString
&
newUserName
,
bool
storeToDisk
,
const
QString
&
oldUserName
,
const
QString
&
newDbId
)
bool
Accounts
::
prepareChangeUserName
(
const
QVariant
&
acntModelVariant
,
const
QString
&
loginMetod
,
const
QString
&
acntName
,
const
QString
&
newUserName
,
const
QString
&
pwd
,
bool
isTestAccount
,
bool
rememberPwd
,
bool
storeToDisk
,
const
QString
&
certPath
,
const
QString
&
oldUserName
)
{
QString
errTxt
;
/* Show confirm dialogue about use name changing */
int
msgResponse
=
Dialogues
::
message
(
Dialogues
::
QUESTION
,
...
...
@@ -436,13 +434,31 @@ bool Accounts::changeAccountUserName(const QVariant &acntModelVariant,
return
false
;
}
return
createAccount
(
acntModelVariant
,
loginMetod
,
acntName
,
newUserName
,
pwd
,
isTestAccount
,
rememberPwd
,
storeToDisk
,
certPath
);
}
bool
Accounts
::
changeAccountUserName
(
const
QVariant
&
acntModelVariant
,
const
QString
&
acntName
,
const
QString
&
newUserName
,
bool
storeToDisk
,
const
QString
&
oldUserName
,
const
QString
&
newDbId
)
{
QString
errTxt
;
AccountListModel
*
accountModel
=
Q_NULLPTR
;
if
(
Q_UNLIKELY
((
GlobInstcs
::
acntMapPtr
==
Q_NULLPTR
)
||
(
GlobInstcs
::
fileDbsPtr
==
Q_NULLPTR
)
||
(
GlobInstcs
::
messageDbsPtr
==
Q_NULLPTR
)))
{
Q_ASSERT
(
0
);
goto
exit
;
}
/* Get account model */
AccountListModel
*
accountModel
=
AccountListModel
::
fromVariant
(
acntModelVariant
);
accountModel
=
AccountListModel
::
fromVariant
(
acntModelVariant
);
if
(
accountModel
==
Q_NULLPTR
)
{
Q_ASSERT
(
0
);
logErrorNL
(
"%s"
,
"Cannot access account model."
);
return
false
;
goto
exit
;
}
/* Check if new user name corresponds with databox id */
...
...
@@ -467,10 +483,10 @@ bool Accounts::changeAccountUserName(const QVariant &acntModelVariant,
goto
rollbackFilesChanges
;
}
/* Delete isds session context of old account */
//emit removeIsdsCtx(oldUserName);
/* Remove old account */
accountModel
->
deleteAccount
(
oldUserName
);
/* Delete isds session context of old account */
emit
removeIsdsCtx
(
oldUserName
);
/* Load message counters of new account */
loadModelCounters
(
accountModel
);
...
...
@@ -506,6 +522,13 @@ fail:
tr
(
"The new user name '%1' for account '%2' has not been set!"
).
arg
(
newUserName
).
arg
(
acntName
),
errTxt
+
" "
+
tr
(
"Account will use the original settings."
));
exit:
/* Remove new account */
accountModel
->
deleteAccount
(
newUserName
);
/* Delete isds session context of new account */
emit
removeIsdsCtx
(
newUserName
);
return
false
;
}
...
...
src/accounts.h
View file @
9b9ca650
...
...
@@ -104,7 +104,7 @@ public:
* @param[in] certPath Certificate path (can be null).
* @return True if success.
*/
Q_INVOKABLE
Q_INVOKABLE
static
bool
createAccount
(
const
QVariant
&
acntModelVariant
,
const
QString
&
loginMetod
,
const
QString
&
acntName
,
const
QString
&
userName
,
const
QString
&
pwd
,
bool
isTestAccount
,
...
...
@@ -116,7 +116,7 @@ public:
* @param[in,out] acntModelVariant QVariant holding account model.
* @param[in] loginMetod User name identifying account.
* @param[in] acntName Account name.
* @param[in]
newU
serName User name identifying account.
* @param[in]
u
serName User name identifying account.
* @param[in] pwd Password.
* @param[in] isTestAccount True if account is isds test enveiroment.
* @param[in] rememberPwd True if remember password.
...
...
@@ -127,7 +127,7 @@ public:
Q_INVOKABLE
bool
updateAccount
(
const
QVariant
&
acntModelVariant
,
const
QString
&
loginMetod
,
const
QString
&
acntName
,
const
QString
&
newU
serName
,
const
QString
&
pwd
,
bool
isTestAccount
,
const
QString
&
u
serName
,
const
QString
&
pwd
,
bool
isTestAccount
,
bool
rememberPwd
,
bool
storeToDisk
,
const
QString
&
certPath
);
/*!
...
...
@@ -141,6 +141,36 @@ public:
bool
removeAccount
(
const
QVariant
&
acntModelVariant
,
const
QString
&
userName
,
bool
showDialogue
);
/*!
* @brief Loads model counters from database.
*
* @param[in,out] accountModel Model whose counters should be updated.
*/
static
void
loadModelCounters
(
AccountListModel
*
accountModel
);
/*!
* @brief Prepare change account user name.
*
* @param[in,out] acntModelVariant QVariant holding account model.
* @param[in] loginMetod User name identifying account.
* @param[in] acntName Account name.
* @param[in] newUserName User name identifying account.
* @param[in] pwd Password.
* @param[in] isTestAccount True if account is isds test enveiroment.
* @param[in] rememberPwd True if remember password.
* @param[in] storeToDisk True if database store to local storage.
* @param[in] certPath Certificate path (can be null).
* @param[in] oldUserName Original user name of account.
* @return True if success.
*/
Q_INVOKABLE
bool
prepareChangeUserName
(
const
QVariant
&
acntModelVariant
,
const
QString
&
loginMetod
,
const
QString
&
acntName
,
const
QString
&
newUserName
,
const
QString
&
pwd
,
bool
isTestAccount
,
bool
rememberPwd
,
bool
storeToDisk
,
const
QString
&
certPath
,
const
QString
&
oldUserName
);
/*!
* @brief Change account user name and update account settings.
*
...
...
@@ -157,14 +187,6 @@ public:
const
QString
&
acntName
,
const
QString
&
newUserName
,
bool
storeToDisk
,
const
QString
&
oldUserName
,
const
QString
&
newDbId
);
/*!
* @brief Loads model counters from database.
*
* @param[in,out] accountModel Model whose counters should be updated.
*/
static
void
loadModelCounters
(
AccountListModel
*
accountModel
);
signals:
/*!
* @brief Send account settings to QML settings page.
...
...
@@ -221,6 +243,7 @@ private:
* @param[in] userName New user name identifying account.
* @return True if length is correct.
*/
static
bool
checkCorrectLengthUserName
(
const
QString
&
userName
);
/*!
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment