Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
mobile Datovka
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
14
Issues
14
List
Boards
Labels
Service Desk
Milestones
Merge Requests
4
Merge Requests
4
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Datovka projects
mobile Datovka
Commits
a26a343d
Commit
a26a343d
authored
Nov 15, 2018
by
Karel Slaný
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed isRelevantUserNameToDbId() from Accounts interface.
parent
29b729e2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
30 deletions
+33
-30
qml/pages/PageSettingsAccount.qml
qml/pages/PageSettingsAccount.qml
+10
-10
src/accounts.cpp
src/accounts.cpp
+23
-10
src/accounts.h
src/accounts.h
+0
-10
No files found.
qml/pages/PageSettingsAccount.qml
View file @
a26a343d
...
...
@@ -100,22 +100,22 @@ Item {
if
(
userNameTextField
.
text
.
toString
()
!==
oldUserName
)
{
// Create temporary account with a new user name.
if
(
accounts
.
prepareChangeUserName
(
accountModel
,
sLoginMethod
,
accountNameTextField
.
text
.
toString
(),
userNameTextField
.
text
.
toString
(),
passwordTextField
.
text
.
toString
(),
testAccount
.
checked
,
rememberPassword
.
checked
,
useLS
.
checked
,
certPathLabelId
.
text
.
toString
(),
oldUserName
))
{
accountNameTextField
.
text
.
toString
(),
userNameTextField
.
text
.
toString
(),
passwordTextField
.
text
.
toString
(),
testAccount
.
checked
,
rememberPassword
.
checked
,
useLS
.
checked
,
certPathLabelId
.
text
.
toString
(),
oldUserName
))
{
// Login to isds with the new user name.
isds
.
doIsdsAction
(
"
changeUserName
"
,
userNameTextField
.
text
.
toString
())
}
}
else
{
// Update account context data.
if
(
accounts
.
updateAccount
(
accountModel
,
sLoginMethod
,
accountNameTextField
.
text
.
toString
(),
userNameTextField
.
text
.
toString
(),
passwordTextField
.
text
.
toString
(),
testAccount
.
checked
,
rememberPassword
.
checked
,
useLS
.
checked
,
certPathLabelId
.
text
.
toString
()))
{
accountNameTextField
.
text
.
toString
(),
userNameTextField
.
text
.
toString
(),
passwordTextField
.
text
.
toString
(),
testAccount
.
checked
,
rememberPassword
.
checked
,
useLS
.
checked
,
certPathLabelId
.
text
.
toString
()))
{
settings
.
saveAllSettings
(
accountModel
)
}
}
...
...
src/accounts.cpp
View file @
a26a343d
...
...
@@ -440,6 +440,24 @@ bool Accounts::prepareChangeUserName(const QVariant &acntModelVariant,
certPath
);
}
/*!
* @brief Check whether the box identifier matches the username of a known account.
*
* @param[in] dbId Data box ID.
* @param[in] username User name of already existing account.
* @return True if username corresponds to data box id, false on any error.
*/
static
bool
boxMatchesUser
(
const
QString
&
dbId
,
const
QString
&
username
)
{
if
(
Q_UNLIKELY
(
dbId
.
isEmpty
()
||
username
.
isEmpty
()))
{
Q_ASSERT
(
0
);
return
false
;
}
return
dbId
==
GlobInstcs
::
accountDbPtr
->
dbId
(
username
);
}
bool
Accounts
::
changeAccountUserName
(
const
QVariant
&
acntModelVariant
,
const
QString
&
acntName
,
const
QString
&
newUserName
,
bool
storeToDisk
,
const
QString
&
oldUserName
,
const
QString
&
newDbId
)
...
...
@@ -458,15 +476,16 @@ bool Accounts::changeAccountUserName(const QVariant &acntModelVariant,
/* Get account model */
accountModel
=
AccountListModel
::
fromVariant
(
acntModelVariant
);
if
(
accountModel
==
Q_NULLPTR
)
{
if
(
Q_UNLIKELY
(
accountModel
==
Q_NULLPTR
)
)
{
Q_ASSERT
(
0
);
logErrorNL
(
"%s"
,
"Cannot access account model."
);
goto
exit
;
}
/* Check if new user name corresponds with databox id */
if
(
!
isRelevantUserNameToDbId
(
oldUserName
,
newDbId
))
{
errTxt
=
tr
(
"New user name '%1' not corresponds with databox ID."
).
arg
(
newUserName
);
/* Check if new user name corresponds with data box id. */
if
(
!
boxMatchesUser
(
newDbId
,
oldUserName
))
{
errTxt
=
tr
(
"New data box identifier '%1' does not correspond with the user name '%2'."
)
.
arg
(
newDbId
).
arg
(
newUserName
);
goto
fail
;
}
...
...
@@ -580,12 +599,6 @@ bool Accounts::hasCorrectLengthUserName(const QString &userName)
return
(
userName
.
length
()
==
6
);
}
bool
Accounts
::
isRelevantUserNameToDbId
(
const
QString
&
userName
,
const
QString
&
dbId
)
{
/* Check if new user corresponds with databox id */
return
(
dbId
==
GlobInstcs
::
accountDbPtr
->
dbId
(
userName
));
}
void
Accounts
::
deleteAccountFromModel
(
AccountListModel
*
accountModel
,
const
QString
&
userName
)
{
...
...
src/accounts.h
View file @
a26a343d
...
...
@@ -246,16 +246,6 @@ private:
static
bool
hasCorrectLengthUserName
(
const
QString
&
userName
);
/*!
* @brief Check if new user name is relevant to databox id.
*
* @param[in] userName Original user name of account.
* @param[in] dbId Databox ID obtained from isds.
* @return True if user name is relevant to databox id.
*/
bool
isRelevantUserNameToDbId
(
const
QString
&
userName
,
const
QString
&
dbId
);
/*!
* @brief Delete account from model.
*
...
...
Write
Preview
Markdown
is supported
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