Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Lucas SCHMIDT
sight
Commits
bef282a8
Verified
Commit
bef282a8
authored
Sep 06, 2021
by
Didier WECKMANN
Browse files
misc: apply review suggestions
parent
bdb5aec4
Changes
6
Hide whitespace changes
Inline
Side-by-side
libs/io/session/PasswordKeeper.cpp
View file @
bef282a8
...
...
@@ -89,6 +89,13 @@ public:
return
core
::
crypto
::
decrypt
(
m_password
,
computePasswordKey
())
==
password
;
}
//------------------------------------------------------------------------------
inline
void
resetPassword
()
{
m_password
.
clear
();
}
private:
/// Generate a pseudo random password key to store the password obfuscated
...
...
@@ -139,6 +146,13 @@ bool PasswordKeeper::checkPassword(const core::crypto::secure_string& password)
//------------------------------------------------------------------------------
void
PasswordKeeper
::
resetPassword
()
{
return
m_pimpl
->
resetPassword
();
}
//------------------------------------------------------------------------------
core
::
crypto
::
secure_string
PasswordKeeper
::
getGlobalPasswordHash
()
{
return
core
::
crypto
::
hash
(
PasswordKeeper
::
getGlobalPassword
());
...
...
@@ -170,4 +184,13 @@ bool PasswordKeeper::checkGlobalPassword(const core::crypto::secure_string& pass
return
core
::
crypto
::
decrypt
(
s_password
,
computeGlobalPasswordKey
())
==
password
;
}
//------------------------------------------------------------------------------
void
PasswordKeeper
::
resetGlobalPassword
()
{
std
::
lock_guard
guard
(
s_password_mutex
);
s_password
.
clear
();
}
}
// namespace sight::io::session
libs/io/session/PasswordKeeper.hpp
View file @
bef282a8
...
...
@@ -82,12 +82,18 @@ public:
/// @param password the password to verify against global stored password
IO_SESSION_API
static
bool
checkGlobalPassword
(
const
core
::
crypto
::
secure_string
&
password
);
/// Reset the global password
IO_SESSION_API
static
void
resetGlobalPassword
();
/// Gets the password
IO_SESSION_API
core
::
crypto
::
secure_string
getPasswordHash
()
const
;
/// Gets the password
IO_SESSION_API
core
::
crypto
::
secure_string
getPassword
()
const
;
/// Reset the password
IO_SESSION_API
void
resetPassword
();
/// Sets the password
/// @param password the new password
IO_SESSION_API
void
setPassword
(
const
core
::
crypto
::
secure_string
&
password
);
...
...
libs/ui/qml/dialog/InputDialog.cpp
View file @
bef282a8
...
...
@@ -38,6 +38,13 @@ namespace sight::ui::qml
namespace
dialog
{
static
auto
enumRegistered
=
[]
{
qmlRegisterUncreatableType
<
InputDialog
>
(
"sight.InputDialog"
,
1
,
0
,
"EchoMode"
,
"Enum EchoMode is not a type"
);
return
true
;
}();
//------------------------------------------------------------------------------
InputDialog
::
InputDialog
(
ui
::
base
::
GuiBaseObject
::
Key
)
...
...
@@ -68,7 +75,7 @@ void InputDialog::setMessage(const std::string& msg)
void
InputDialog
::
setEchoMode
(
base
::
dialog
::
IInputDialog
::
EchoMode
echoMode
)
{
m_echoMode
=
static_cast
<
decltype
(
m_echoMode
)
>
(
echoMode
)
;
m_echoMode
=
echoMode
;
}
//------------------------------------------------------------------------------
...
...
libs/ui/qml/dialog/InputDialog.hpp
View file @
bef282a8
...
...
@@ -54,10 +54,11 @@ class UI_QML_CLASS_API InputDialog : public QObject,
public
ui
::
base
::
dialog
::
IInputDialog
{
Q_OBJECT
Q_ENUM
(
EchoMode
)
Q_PROPERTY
(
QString
input
MEMBER
m_input
NOTIFY
inputChanged
)
Q_PROPERTY
(
QString
message
MEMBER
m_message
NOTIFY
messageChanged
)
Q_PROPERTY
(
QString
title
MEMBER
m_title
NOTIFY
titleChanged
)
Q_PROPERTY
(
std
::
uint8_t
echoMode
MEMBER
m_echoMode
NOTIFY
echoModeChanged
)
Q_PROPERTY
(
EchoMode
echoMode
MEMBER
m_echoMode
NOTIFY
echoModeChanged
)
public:
...
...
@@ -107,7 +108,7 @@ private:
QString
m_input
;
/// Echo mode for the TextField
std
::
uint8_t
m_echoMode
;
EchoMode
m_echoMode
{
EchoMode
::
DEFAULT
}
;
};
}
// namespace dialog
...
...
libs/ui/qml/rc/dialog/InputDialog.qml
View file @
bef282a8
...
...
@@ -5,6 +5,7 @@ import QtQuick.Layouts 1.12
import
QtQuick
.
Window
2.12
import
sight
.
style
1.0
import
sight
.
InputDialog
1.0
Window
{
id
:
window
...
...
@@ -39,7 +40,7 @@ Window {
id
:
answer
Layout.fillWidth
:
true
placeholderText
:
inputDialog
.
input
echoMode
:
inputDialog
.
echoMode
==
1
?
TextInput
.
NoEcho
:
inputDialog
.
echoMode
==
2
?
TextInput
.
Password
:
inputDialog
.
echoMode
==
3
?
TextInput
.
PasswordEchoOnEdit
:
TextInput
.
Normal
echoMode
:
inputDialog
.
echoMode
==
EchoMode
.
NOECHO
?
TextInput
.
NoEcho
:
inputDialog
.
echoMode
==
EchoMode
.
PASSWORD
?
TextInput
.
Password
:
inputDialog
.
echoMode
==
EchoMode
.
ECHO_ON_EDIT
?
TextInput
.
PasswordEchoOnEdit
:
TextInput
.
Normal
}
}
...
...
modules/io/session/SReader.cpp
View file @
bef282a8
...
...
@@ -208,7 +208,7 @@ void SReader::updating()
"Enter Password"
,
"Password:"
,
globalPassword
.
c_str
(),
sight
::
ui
::
base
::
dialog
::
InputDialog
::
EchoMode
::
ECHO_ON_EDIT
sight
::
ui
::
base
::
dialog
::
InputDialog
::
EchoMode
::
PASSWORD
)
);
...
...
@@ -292,6 +292,12 @@ void SReader::updating()
else
{
m_pimpl
->
m_passwordRetry
=
0
;
// Reset old wrong password
if
(
m_pimpl
->
m_passwordPolicy
==
PasswordKeeper
::
PasswordPolicy
::
ONCE
)
{
PasswordKeeper
::
resetGlobalPassword
();
}
}
}
catch
(
std
::
exception
&
_e
)
...
...
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