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
f41aa467
Commit
f41aa467
authored
Jul 16, 2018
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Proper save and clear data when login in and out
parent
1df80b20
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
13 deletions
+62
-13
LoginPresenter.kt
...droid/authentication/login/presentation/LoginPresenter.kt
+56
-8
SharedPreferencesLocalRepository.kt
...ndroid/infrastructure/SharedPreferencesLocalRepository.kt
+6
-5
No files found.
app/src/main/java/chat/rocket/android/authentication/login/presentation/LoginPresenter.kt
View file @
f41aa467
...
...
@@ -5,19 +5,58 @@ import chat.rocket.android.authentication.presentation.AuthenticationNavigator
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.helper.OauthHelper
import
chat.rocket.android.infrastructure.LocalRepository
import
chat.rocket.android.server.domain.*
import
chat.rocket.android.server.domain.GetAccountsInteractor
import
chat.rocket.android.server.domain.GetConnectingServerInteractor
import
chat.rocket.android.server.domain.GetSettingsInteractor
import
chat.rocket.android.server.domain.PublicSettings
import
chat.rocket.android.server.domain.SaveAccountInteractor
import
chat.rocket.android.server.domain.SaveCurrentServerInteractor
import
chat.rocket.android.server.domain.TokenRepository
import
chat.rocket.android.server.domain.casLoginUrl
import
chat.rocket.android.server.domain.favicon
import
chat.rocket.android.server.domain.gitlabUrl
import
chat.rocket.android.server.domain.isCasAuthenticationEnabled
import
chat.rocket.android.server.domain.isFacebookAuthenticationEnabled
import
chat.rocket.android.server.domain.isGithubAuthenticationEnabled
import
chat.rocket.android.server.domain.isGitlabAuthenticationEnabled
import
chat.rocket.android.server.domain.isGoogleAuthenticationEnabled
import
chat.rocket.android.server.domain.isLdapAuthenticationEnabled
import
chat.rocket.android.server.domain.isLinkedinAuthenticationEnabled
import
chat.rocket.android.server.domain.isLoginFormEnabled
import
chat.rocket.android.server.domain.isMeteorAuthenticationEnabled
import
chat.rocket.android.server.domain.isPasswordResetEnabled
import
chat.rocket.android.server.domain.isRegistrationEnabledForNewUsers
import
chat.rocket.android.server.domain.isTwitterAuthenticationEnabled
import
chat.rocket.android.server.domain.model.Account
import
chat.rocket.android.server.domain.wideTile
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
import
chat.rocket.android.util.extension.launchUI
import
chat.rocket.android.util.extensions.*
import
chat.rocket.android.util.extensions.avatarUrl
import
chat.rocket.android.util.extensions.casUrl
import
chat.rocket.android.util.extensions.encodeToBase64
import
chat.rocket.android.util.extensions.generateRandomString
import
chat.rocket.android.util.extensions.isEmail
import
chat.rocket.android.util.extensions.parseColor
import
chat.rocket.android.util.extensions.registerPushToken
import
chat.rocket.android.util.extensions.samlUrl
import
chat.rocket.android.util.extensions.serverLogoUrl
import
chat.rocket.android.util.retryIO
import
chat.rocket.common.RocketChatAuthException
import
chat.rocket.common.RocketChatException
import
chat.rocket.common.RocketChatTwoFactorException
import
chat.rocket.common.model.Email
import
chat.rocket.common.model.Token
import
chat.rocket.common.model.User
import
chat.rocket.common.util.ifNull
import
chat.rocket.core.RocketChatClient
import
chat.rocket.core.internal.rest.*
import
chat.rocket.core.internal.rest.login
import
chat.rocket.core.internal.rest.loginWithCas
import
chat.rocket.core.internal.rest.loginWithEmail
import
chat.rocket.core.internal.rest.loginWithLdap
import
chat.rocket.core.internal.rest.loginWithOauth
import
chat.rocket.core.internal.rest.loginWithSaml
import
chat.rocket.core.internal.rest.me
import
chat.rocket.core.internal.rest.settingsOauth
import
kotlinx.coroutines.experimental.delay
import
timber.log.Timber
import
java.util.concurrent.TimeUnit
...
...
@@ -351,11 +390,20 @@ class LoginPresenter @Inject constructor(
}
}
}
val
username
=
retryIO
(
"me()"
)
{
client
.
me
().
username
}
if
(
username
!=
null
)
{
localRepository
.
save
(
LocalRepository
.
CURRENT_USERNAME_KEY
,
username
)
val
myself
=
retryIO
(
"me()"
)
{
client
.
me
()
}
if
(
myself
.
username
!=
null
)
{
val
user
=
User
(
id
=
myself
.
id
,
roles
=
myself
.
roles
,
status
=
myself
.
status
,
name
=
myself
.
name
,
emails
=
myself
.
emails
?.
map
{
Email
(
it
.
address
?:
""
,
it
.
verified
)
},
username
=
myself
.
username
,
utcOffset
=
myself
.
utcOffset
)
localRepository
.
saveCurrentUser
(
url
=
currentServer
,
user
=
user
)
saveCurrentServer
.
save
(
currentServer
)
saveAccount
(
username
)
saveAccount
(
myself
.
username
!!
)
saveToken
(
token
)
registerPushToken
()
if
(
loginType
==
TYPE_LOGIN_USER_EMAIL
)
{
...
...
@@ -391,7 +439,7 @@ class LoginPresenter @Inject constructor(
}.
toString
()
}
private
fun
getSamlServices
(
listMap
:
List
<
Map
<
String
,
Any
>>):
List
<
Map
<
String
,
Any
>>
{
private
fun
getSamlServices
(
listMap
:
List
<
Map
<
String
,
Any
>>):
List
<
Map
<
String
,
Any
>>
{
return
listMap
.
filter
{
map
->
map
[
"service"
]
==
"saml"
}
}
...
...
app/src/main/java/chat/rocket/android/infrastructure/SharedPreferencesLocalRepository.kt
View file @
f41aa467
...
...
@@ -52,9 +52,10 @@ class SharedPreferencesLocalRepository(
override
fun
clear
(
key
:
String
)
=
preferences
.
edit
{
remove
(
key
)
}
override
fun
clearAllFromServer
(
server
:
String
)
{
clear
(
LocalRepository
.
KEY_PUSH_TOKEN
)
clear
(
LocalRepository
.
TOKEN_KEY
+
server
)
clear
(
LocalRepository
.
SETTINGS_KEY
+
server
)
clear
(
LocalRepository
.
CURRENT_USERNAME_KEY
)
preferences
.
all
.
keys
.
forEach
{
key
->
if
(
key
.
startsWith
(
server
,
ignoreCase
=
true
))
{
clear
(
key
)
}
}
}
}
\ No newline at end of file
}
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