Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nheko
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nheko Reborn
nheko
Commits
ebd12a6f
Commit
ebd12a6f
authored
4 years ago
by
Nicolas Werner
Browse files
Options
Downloads
Patches
Plain Diff
Fix login with SSO and Password supported
parent
99efe2f0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Checking pipeline status
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/LoginPage.cpp
+29
-18
29 additions, 18 deletions
src/LoginPage.cpp
src/LoginPage.h
+6
-5
6 additions, 5 deletions
src/LoginPage.h
with
35 additions
and
23 deletions
src/LoginPage.cpp
+
29
−
18
View file @
ebd12a6f
...
...
@@ -147,16 +147,23 @@ LoginPage::LoginPage(QWidget *parent)
error_matrixid_label_
->
hide
();
button_layout_
=
new
QHBoxLayout
();
button_layout_
->
setSpacing
(
0
);
button_layout_
->
setSpacing
(
2
0
);
button_layout_
->
setContentsMargins
(
0
,
0
,
0
,
30
);
login_button_
=
new
RaisedButton
(
tr
(
"LOGIN"
),
this
);
login_button_
->
setMinimumSize
(
3
50
,
65
);
login_button_
->
setMinimumSize
(
1
50
,
65
);
login_button_
->
setFontSize
(
20
);
login_button_
->
setCornerRadius
(
3
);
sso_login_button_
=
new
RaisedButton
(
tr
(
"SSO LOGIN"
),
this
);
sso_login_button_
->
setMinimumSize
(
150
,
65
);
sso_login_button_
->
setFontSize
(
20
);
sso_login_button_
->
setCornerRadius
(
3
);
sso_login_button_
->
setVisible
(
false
);
button_layout_
->
addStretch
(
1
);
button_layout_
->
addWidget
(
login_button_
);
button_layout_
->
addWidget
(
sso_login_button_
);
button_layout_
->
addStretch
(
1
);
error_label_
=
new
QLabel
(
this
);
...
...
@@ -179,7 +186,12 @@ LoginPage::LoginPage(QWidget *parent)
this
,
&
LoginPage
::
versionErrorCb
,
this
,
&
LoginPage
::
versionError
,
Qt
::
QueuedConnection
);
connect
(
back_button_
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
onBackButtonClicked
()));
connect
(
login_button_
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
onLoginButtonClicked
()));
connect
(
login_button_
,
&
RaisedButton
::
clicked
,
this
,
[
this
]()
{
onLoginButtonClicked
(
passwordSupported
?
LoginMethod
::
Password
:
LoginMethod
::
SSO
);
});
connect
(
sso_login_button_
,
&
RaisedButton
::
clicked
,
this
,
[
this
]()
{
onLoginButtonClicked
(
LoginMethod
::
SSO
);
});
connect
(
matrixid_input_
,
SIGNAL
(
returnPressed
()),
login_button_
,
SLOT
(
click
()));
connect
(
password_input_
,
SIGNAL
(
returnPressed
()),
login_button_
,
SLOT
(
click
()));
connect
(
deviceName_
,
SIGNAL
(
returnPressed
()),
login_button_
,
SLOT
(
click
()));
...
...
@@ -314,16 +326,19 @@ LoginPage::checkHomeserverVersion()
http
::
client
()
->
get_login
(
[
this
](
mtx
::
responses
::
LoginFlows
flows
,
mtx
::
http
::
RequestErr
err
)
{
if
(
err
||
flows
.
flows
.
empty
())
emit
versionOkCb
(
LoginMethod
::
Password
);
emit
versionOkCb
(
true
,
false
);
LoginMethod
loginMethod_
=
LoginMethod
::
Password
;
bool
ssoSupported_
=
false
;
bool
passwordSupported_
=
false
;
for
(
const
auto
&
flow
:
flows
.
flows
)
{
if
(
flow
.
type
==
mtx
::
user_interactive
::
auth_types
::
sso
)
{
loginMethod_
=
LoginMethod
::
SSO
;
break
;
ssoSupported_
=
true
;
}
else
if
(
flow
.
type
==
mtx
::
user_interactive
::
auth_types
::
password
)
{
passwordSupported_
=
true
;
}
}
emit
versionOkCb
(
loginMetho
d_
);
emit
versionOkCb
(
passwordSupported_
,
ssoSupporte
d_
);
});
});
}
...
...
@@ -355,28 +370,24 @@ LoginPage::versionError(const QString &error)
}
void
LoginPage
::
versionOk
(
LoginMethod
loginMetho
d_
)
LoginPage
::
versionOk
(
bool
passwordSupported_
,
bool
ssoSupporte
d_
)
{
this
->
loginMethod
=
loginMethod_
;
passwordSupported
=
passwordSupported_
;
ssoSupported
=
ssoSupported_
;
serverLayout_
->
removeWidget
(
spinner_
);
matrixidLayout_
->
removeWidget
(
spinner_
);
spinner_
->
stop
();
if
(
loginMethod
==
LoginMethod
::
SSO
)
{
password_input_
->
hide
();
login_button_
->
setText
(
tr
(
"SSO LOGIN"
));
}
else
{
password_input_
->
show
();
login_button_
->
setText
(
tr
(
"LOGIN"
));
}
sso_login_button_
->
setVisible
(
ssoSupported
);
login_button_
->
setVisible
(
passwordSupported
);
if
(
serverInput_
->
isVisible
())
serverInput_
->
hide
();
}
void
LoginPage
::
onLoginButtonClicked
()
LoginPage
::
onLoginButtonClicked
(
LoginMethod
loginMethod
)
{
error_label_
->
setText
(
""
);
...
...
This diff is collapsed.
Click to expand it.
src/LoginPage.h
+
6
−
5
View file @
ebd12a6f
...
...
@@ -56,7 +56,7 @@ signals:
//! Used to trigger the corresponding slot outside of the main thread.
void
versionErrorCb
(
const
QString
&
err
);
void
versionOkCb
(
LoginPage
::
LoginMethod
metho
d
);
void
versionOkCb
(
bool
passwordSupported
,
bool
ssoSupporte
d
);
void
loginOk
(
const
mtx
::
responses
::
Login
&
res
);
...
...
@@ -73,7 +73,7 @@ private slots:
void
onBackButtonClicked
();
// Callback for the login button.
void
onLoginButtonClicked
();
void
onLoginButtonClicked
(
LoginMethod
loginMethod
);
// Callback for probing the server found in the mxid
void
onMatrixIdEntered
();
...
...
@@ -84,7 +84,7 @@ private slots:
// Callback for errors produced during server probing
void
versionError
(
const
QString
&
error_message
);
// Callback for successful server probing
void
versionOk
(
LoginPage
::
LoginMethod
metho
d
);
void
versionOk
(
bool
passwordSupported
,
bool
ssoSupporte
d
);
private
:
void
checkHomeserverVersion
();
...
...
@@ -120,7 +120,7 @@ private:
QString
inferredServerAddress_
;
FlatButton
*
back_button_
;
RaisedButton
*
login_button_
;
RaisedButton
*
login_button_
,
*
sso_login_button_
;
QWidget
*
form_widget_
;
QHBoxLayout
*
form_wrapper_
;
...
...
@@ -130,5 +130,6 @@ private:
TextField
*
password_input_
;
TextField
*
deviceName_
;
TextField
*
serverInput_
;
LoginMethod
loginMethod
=
LoginMethod
::
Password
;
bool
passwordSupported
=
true
;
bool
ssoSupported
=
false
;
};
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment