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
a63ed591
Unverified
Commit
a63ed591
authored
Mar 06, 2018
by
Filipe de Lima Brito
Committed by
GitHub
Mar 06, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #855 from RocketChat/feature/login-with-ldap
[NEW] Login with ldap
parents
8e746265
ff4f95e2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
15 deletions
+25
-15
LoginPresenter.kt
...droid/authentication/login/presentation/LoginPresenter.kt
+24
-15
SettingsRepository.kt
...a/chat/rocket/android/server/domain/SettingsRepository.kt
+1
-0
No files found.
app/src/main/java/chat/rocket/android/authentication/login/presentation/LoginPresenter.kt
View file @
a63ed591
...
...
@@ -11,12 +11,10 @@ import chat.rocket.android.util.extensions.isEmailValid
import
chat.rocket.android.util.extensions.launchUI
import
chat.rocket.common.RocketChatException
import
chat.rocket.common.RocketChatTwoFactorException
import
chat.rocket.common.model.Token
import
chat.rocket.common.util.ifNull
import
chat.rocket.core.RocketChatClient
import
chat.rocket.core.internal.rest.login
import
chat.rocket.core.internal.rest.loginWithEmail
import
chat.rocket.core.internal.rest.me
import
chat.rocket.core.internal.rest.registerPushToken
import
chat.rocket.core.internal.rest.*
import
javax.inject.Inject
class
LoginPresenter
@Inject
constructor
(
private
val
view
:
LoginView
,
...
...
@@ -95,20 +93,31 @@ class LoginPresenter @Inject constructor(private val view: LoginView,
view
.
showLoading
()
try
{
val
token
=
if
(
usernameOrEmail
.
isEmailValid
())
{
client
.
loginWithEmail
(
usernameOrEmail
,
password
)
var
token
:
Token
?
=
null
if
(
usernameOrEmail
.
isEmailValid
())
{
token
=
client
.
loginWithEmail
(
usernameOrEmail
,
password
)
}
else
{
client
.
login
(
usernameOrEmail
,
password
)
val
settings
=
settingsInteractor
.
get
(
server
)
if
(
settings
!=
null
)
{
token
=
if
(
settings
.
ldapEnabled
())
{
client
.
loginWithLdap
(
usernameOrEmail
,
password
)
}
else
{
client
.
login
(
usernameOrEmail
,
password
)
}
}
else
{
navigator
.
toServerScreen
()
}
}
val
me
=
client
.
me
()
multiServerRepository
.
save
(
server
,
TokenModel
(
token
.
userId
,
token
.
authToken
)
)
localRepository
.
save
(
LocalRepository
.
USERNAME_KEY
,
me
.
username
)
registerPushToken
()
navigator
.
toChatList
()
if
(
token
!=
null
)
{
val
me
=
client
.
me
()
multiServerRepository
.
save
(
server
,
TokenModel
(
token
.
userId
,
token
.
authToken
))
localRepository
.
save
(
LocalRepository
.
USERNAME_KEY
,
me
.
username
)
registerPushToken
()
navigator
.
toChatList
()
}
else
{
view
.
showGenericErrorMessage
()
}
}
catch
(
exception
:
RocketChatException
)
{
when
(
exception
)
{
is
RocketChatTwoFactorException
->
{
...
...
app/src/main/java/chat/rocket/android/server/domain/SettingsRepository.kt
View file @
a63ed591
...
...
@@ -58,6 +58,7 @@ fun PublicSettings.gitlabEnabled(): Boolean = this[ACCOUNT_GITLAB]?.value == tru
fun
PublicSettings
.
wordpressEnabled
():
Boolean
=
this
[
ACCOUNT_WORDPRESS
]
?.
value
==
true
fun
PublicSettings
.
useRealName
():
Boolean
=
this
[
USE_REALNAME
]
?.
value
==
true
fun
PublicSettings
.
ldapEnabled
():
Boolean
=
this
[
LDAP_ENABLE
]
?.
value
==
true
// Message settings
fun
PublicSettings
.
showDeletedStatus
():
Boolean
=
this
[
SHOW_DELETED_STATUS
]
?.
value
==
true
...
...
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