Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AloqaIM-Android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
AloqaIM-Android
Commits
547201c8
Commit
547201c8
authored
Oct 03, 2018
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bug that wasn't showing the login options for the first time.
parent
a8ce982a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
139 additions
and
141 deletions
+139
-141
LoginOptionsFragment.kt
...id/authentication/loginoptions/ui/LoginOptionsFragment.kt
+1
-1
CheckServerPresenter.kt
...ocket/android/server/presentation/CheckServerPresenter.kt
+138
-140
No files found.
app/src/main/java/chat/rocket/android/authentication/loginoptions/ui/LoginOptionsFragment.kt
View file @
547201c8
...
...
@@ -87,7 +87,7 @@ fun newInstance(
deepLinkInfo
:
LoginDeepLinkInfo
?
=
null
):
Fragment
{
return
LoginOptionsFragment
().
apply
{
arguments
=
Bundle
(
19
).
apply
{
arguments
=
Bundle
(
23
).
apply
{
putString
(
SERVER_NAME
,
serverName
)
putString
(
STATE
,
state
)
putString
(
FACEBOOK_OAUTH_URL
,
facebookOauthUrl
)
...
...
app/src/main/java/chat/rocket/android/server/presentation/CheckServerPresenter.kt
View file @
547201c8
...
...
@@ -117,175 +117,173 @@ abstract class CheckServerPresenter constructor(
}
internal
suspend
fun
checkEnabledAccounts
(
serverUrl
:
String
)
{
launchUI
(
strategy
)
{
try
{
val
services
=
retryIO
(
"settingsOauth()"
)
{
client
.
settingsOauth
().
services
}
try
{
val
services
=
retryIO
(
"settingsOauth()"
)
{
client
.
settingsOauth
().
services
}
if
(
services
.
isNotEmpty
())
{
state
=
OauthHelper
.
getState
()
if
(
services
.
isNotEmpty
())
{
state
=
OauthHelper
.
getState
()
// OAuth accounts.
if
(
settings
.
isFacebookAuthenticationEnabled
())
{
getServiceMap
(
services
,
SERVICE_NAME_FACEBOOK
)
?.
let
{
serviceMap
->
getOauthClientId
(
serviceMap
)
?.
let
{
clientId
->
facebookOauthUrl
=
OauthHelper
.
getFacebookOauthUrl
(
clientId
,
serverUrl
,
state
)
totalSocialAccountsEnabled
++
}
// OAuth accounts.
if
(
settings
.
isFacebookAuthenticationEnabled
())
{
getServiceMap
(
services
,
SERVICE_NAME_FACEBOOK
)
?.
let
{
serviceMap
->
getOauthClientId
(
serviceMap
)
?.
let
{
clientId
->
facebookOauthUrl
=
OauthHelper
.
getFacebookOauthUrl
(
clientId
,
serverUrl
,
state
)
totalSocialAccountsEnabled
++
}
}
}
if
(
settings
.
isGithubAuthenticationEnabled
())
{
getServiceMap
(
services
,
SERVICE_NAME_GITHUB
)
?.
let
{
serviceMap
->
getOauthClientId
(
serviceMap
)
?.
let
{
clientId
->
githubOauthUrl
=
OauthHelper
.
getGithubOauthUrl
(
clientId
,
state
)
totalSocialAccountsEnabled
++
}
if
(
settings
.
isGithubAuthenticationEnabled
())
{
getServiceMap
(
services
,
SERVICE_NAME_GITHUB
)
?.
let
{
serviceMap
->
getOauthClientId
(
serviceMap
)
?.
let
{
clientId
->
githubOauthUrl
=
OauthHelper
.
getGithubOauthUrl
(
clientId
,
state
)
totalSocialAccountsEnabled
++
}
}
}
if
(
settings
.
isGoogleAuthenticationEnabled
())
{
getServiceMap
(
services
,
SERVICE_NAME_GOOGLE
)
?.
let
{
serviceMap
->
getOauthClientId
(
serviceMap
)
?.
let
{
clientId
->
googleOauthUrl
=
OauthHelper
.
getGoogleOauthUrl
(
clientId
,
serverUrl
,
state
)
totalSocialAccountsEnabled
++
}
if
(
settings
.
isGoogleAuthenticationEnabled
())
{
getServiceMap
(
services
,
SERVICE_NAME_GOOGLE
)
?.
let
{
serviceMap
->
getOauthClientId
(
serviceMap
)
?.
let
{
clientId
->
googleOauthUrl
=
OauthHelper
.
getGoogleOauthUrl
(
clientId
,
serverUrl
,
state
)
totalSocialAccountsEnabled
++
}
}
}
if
(
settings
.
isLinkedinAuthenticationEnabled
())
{
getServiceMap
(
services
,
SERVICE_NAME_LINKEDIN
)
?.
let
{
serviceMap
->
getOauthClientId
(
serviceMap
)
?.
let
{
clientId
->
linkedinOauthUrl
=
OauthHelper
.
getLinkedinOauthUrl
(
clientId
,
serverUrl
,
state
)
totalSocialAccountsEnabled
++
}
if
(
settings
.
isLinkedinAuthenticationEnabled
())
{
getServiceMap
(
services
,
SERVICE_NAME_LINKEDIN
)
?.
let
{
serviceMap
->
getOauthClientId
(
serviceMap
)
?.
let
{
clientId
->
linkedinOauthUrl
=
OauthHelper
.
getLinkedinOauthUrl
(
clientId
,
serverUrl
,
state
)
totalSocialAccountsEnabled
++
}
}
}
if
(
settings
.
isGitlabAuthenticationEnabled
())
{
getServiceMap
(
services
,
SERVICE_NAME_GILAB
)
?.
let
{
serviceMap
->
getOauthClientId
(
serviceMap
)
?.
let
{
clientId
->
gitlabOauthUrl
=
if
(
settings
.
gitlabUrl
()
!=
null
)
{
OauthHelper
.
getGitlabOauthUrl
(
host
=
settings
.
gitlabUrl
(),
clientId
=
clientId
,
serverUrl
=
serverUrl
,
state
=
state
)
}
else
{
OauthHelper
.
getGitlabOauthUrl
(
clientId
=
clientId
,
serverUrl
=
serverUrl
,
state
=
state
)
}
totalSocialAccountsEnabled
++
if
(
settings
.
isGitlabAuthenticationEnabled
())
{
getServiceMap
(
services
,
SERVICE_NAME_GILAB
)
?.
let
{
serviceMap
->
getOauthClientId
(
serviceMap
)
?.
let
{
clientId
->
gitlabOauthUrl
=
if
(
settings
.
gitlabUrl
()
!=
null
)
{
OauthHelper
.
getGitlabOauthUrl
(
host
=
settings
.
gitlabUrl
(),
clientId
=
clientId
,
serverUrl
=
serverUrl
,
state
=
state
)
}
else
{
OauthHelper
.
getGitlabOauthUrl
(
clientId
=
clientId
,
serverUrl
=
serverUrl
,
state
=
state
)
}
totalSocialAccountsEnabled
++
}
}
}
if
(
settings
.
isWordpressAuthenticationEnabled
())
{
getServiceMap
(
services
,
SERVICE_NAME_WORDPRESS
)
?.
let
{
serviceMap
->
getOauthClientId
(
serviceMap
)
?.
let
{
clientId
->
wordpressOauthUrl
=
if
(
settings
.
wordpressUrl
().
isNullOrEmpty
())
{
OauthHelper
.
getWordpressComOauthUrl
(
clientId
,
serverUrl
,
state
)
}
else
{
OauthHelper
.
getWordpressCustomOauthUrl
(
getCustomOauthHost
(
serviceMap
)
?:
"https://public-api.wordpress.com"
,
getCustomOauthAuthorizePath
(
serviceMap
)
?:
"/oauth/authorize"
,
clientId
,
serverUrl
,
SERVICE_NAME_WORDPRESS
,
state
,
getCustomOauthScope
(
serviceMap
)
?:
"openid"
)
}
totalSocialAccountsEnabled
++
}
if
(
settings
.
isWordpressAuthenticationEnabled
())
{
getServiceMap
(
services
,
SERVICE_NAME_WORDPRESS
)
?.
let
{
serviceMap
->
getOauthClientId
(
serviceMap
)
?.
let
{
clientId
->
wordpressOauthUrl
=
if
(
settings
.
wordpressUrl
().
isNullOrEmpty
())
{
OauthHelper
.
getWordpressComOauthUrl
(
clientId
,
serverUrl
,
state
)
}
else
{
OauthHelper
.
getWordpressCustomOauthUrl
(
getCustomOauthHost
(
serviceMap
)
?:
"https://public-api.wordpress.com"
,
getCustomOauthAuthorizePath
(
serviceMap
)
?:
"/oauth/authorize"
,
clientId
,
serverUrl
,
SERVICE_NAME_WORDPRESS
,
state
,
getCustomOauthScope
(
serviceMap
)
?:
"openid"
)
}
totalSocialAccountsEnabled
++
}
}
}
// CAS account.
if
(
settings
.
isCasAuthenticationEnabled
())
{
casToken
=
generateRandomString
(
17
)
casLoginUrl
=
settings
.
casLoginUrl
().
casUrl
(
serverUrl
,
casToken
.
toString
())
totalSocialAccountsEnabled
++
}
// CAS account.
if
(
settings
.
isCasAuthenticationEnabled
())
{
casToken
=
generateRandomString
(
17
)
casLoginUrl
=
settings
.
casLoginUrl
().
casUrl
(
serverUrl
,
casToken
.
toString
())
totalSocialAccountsEnabled
++
}
// Custom OAuth account.
getCustomOauthServices
(
services
).
let
{
for
(
serviceMap
in
it
)
{
customOauthServiceName
=
getCustomOauthServiceName
(
serviceMap
)
val
host
=
getCustomOauthHost
(
serviceMap
)
val
authorizePath
=
getCustomOauthAuthorizePath
(
serviceMap
)
val
clientId
=
getOauthClientId
(
serviceMap
)
val
scope
=
getCustomOauthScope
(
serviceMap
)
val
serviceNameTextColor
=
getServiceNameColorForCustomOauthOrSaml
(
serviceMap
)
val
serviceButtonColor
=
getServiceButtonColor
(
serviceMap
)
if
(
customOauthServiceName
!=
null
&&
host
!=
null
&&
authorizePath
!=
null
&&
clientId
!=
null
&&
scope
!=
null
&&
serviceNameTextColor
!=
null
&&
serviceButtonColor
!=
null
)
{
customOauthUrl
=
OauthHelper
.
getCustomOauthUrl
(
host
,
authorizePath
,
clientId
,
serverUrl
,
customOauthServiceName
.
toString
(),
state
,
scope
)
customOauthServiceNameTextColor
=
serviceNameTextColor
customOauthServiceButtonColor
=
serviceButtonColor
totalSocialAccountsEnabled
++
}
// Custom OAuth account.
getCustomOauthServices
(
services
).
let
{
for
(
serviceMap
in
it
)
{
customOauthServiceName
=
getCustomOauthServiceName
(
serviceMap
)
val
host
=
getCustomOauthHost
(
serviceMap
)
val
authorizePath
=
getCustomOauthAuthorizePath
(
serviceMap
)
val
clientId
=
getOauthClientId
(
serviceMap
)
val
scope
=
getCustomOauthScope
(
serviceMap
)
val
serviceNameTextColor
=
getServiceNameColorForCustomOauthOrSaml
(
serviceMap
)
val
serviceButtonColor
=
getServiceButtonColor
(
serviceMap
)
if
(
customOauthServiceName
!=
null
&&
host
!=
null
&&
authorizePath
!=
null
&&
clientId
!=
null
&&
scope
!=
null
&&
serviceNameTextColor
!=
null
&&
serviceButtonColor
!=
null
)
{
customOauthUrl
=
OauthHelper
.
getCustomOauthUrl
(
host
,
authorizePath
,
clientId
,
serverUrl
,
customOauthServiceName
.
toString
(),
state
,
scope
)
customOauthServiceNameTextColor
=
serviceNameTextColor
customOauthServiceButtonColor
=
serviceButtonColor
totalSocialAccountsEnabled
++
}
}
}
// SAML account.
getSamlServices
(
services
).
let
{
samlToken
=
generateRandomString
(
17
)
for
(
serviceMap
in
it
)
{
val
provider
=
getSamlProvider
(
serviceMap
)
samlServiceName
=
getSamlServiceName
(
serviceMap
)
val
serviceNameTextColor
=
getServiceNameColorForCustomOauthOrSaml
(
serviceMap
)
val
serviceButtonColor
=
getServiceButtonColor
(
serviceMap
)
if
(
provider
!=
null
&&
samlServiceName
!=
null
&&
serviceNameTextColor
!=
null
&&
serviceButtonColor
!=
null
)
{
samlUrl
=
serverUrl
.
samlUrl
(
provider
,
samlToken
.
toString
())
samlServiceNameTextColor
=
serviceNameTextColor
samlServiceButtonColor
=
serviceButtonColor
totalSocialAccountsEnabled
++
}
// SAML account.
getSamlServices
(
services
).
let
{
samlToken
=
generateRandomString
(
17
)
for
(
serviceMap
in
it
)
{
val
provider
=
getSamlProvider
(
serviceMap
)
samlServiceName
=
getSamlServiceName
(
serviceMap
)
val
serviceNameTextColor
=
getServiceNameColorForCustomOauthOrSaml
(
serviceMap
)
val
serviceButtonColor
=
getServiceButtonColor
(
serviceMap
)
if
(
provider
!=
null
&&
samlServiceName
!=
null
&&
serviceNameTextColor
!=
null
&&
serviceButtonColor
!=
null
)
{
samlUrl
=
serverUrl
.
samlUrl
(
provider
,
samlToken
.
toString
())
samlServiceNameTextColor
=
serviceNameTextColor
samlServiceButtonColor
=
serviceButtonColor
totalSocialAccountsEnabled
++
}
}
}
}
catch
(
exception
:
RocketChatException
)
{
Timber
.
e
(
exception
)
}
}
catch
(
exception
:
RocketChatException
)
{
Timber
.
e
(
exception
)
}
}
...
...
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