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
05e29725
Unverified
Commit
05e29725
authored
Apr 02, 2018
by
Rafael Kellermann Streit
Committed by
GitHub
Apr 02, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1002 from RocketChat/fix/logout-when-invalid-token
[FIX] Logout on invalid token.
parents
c77a4dba
b16d2ccc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
16 deletions
+31
-16
MainPresenter.kt
...va/chat/rocket/android/main/presentation/MainPresenter.kt
+25
-10
NavHeaderViewModelMapper.kt
...rocket/android/main/viewmodel/NavHeaderViewModelMapper.kt
+5
-5
SettingsRepository.kt
...a/chat/rocket/android/server/domain/SettingsRepository.kt
+1
-1
No files found.
app/src/main/java/chat/rocket/android/main/presentation/MainPresenter.kt
View file @
05e29725
...
...
@@ -12,6 +12,7 @@ import chat.rocket.android.server.infraestructure.RocketChatClientFactory
import
chat.rocket.android.server.presentation.CheckServerPresenter
import
chat.rocket.android.util.extensions.launchUI
import
chat.rocket.android.util.extensions.registerPushToken
import
chat.rocket.common.RocketChatAuthException
import
chat.rocket.common.RocketChatException
import
chat.rocket.common.util.ifNull
import
chat.rocket.core.RocketChatClient
...
...
@@ -57,11 +58,18 @@ class MainPresenter @Inject constructor(
saveAccount
(
model
)
view
.
setupNavHeader
(
model
,
getAccountsInteractor
.
get
())
}
catch
(
ex
:
Exception
)
{
Timber
.
d
(
ex
,
"Error loading my information for navheader"
)
ex
.
message
?.
let
{
view
.
showMessage
(
it
)
}.
ifNull
{
view
.
showGenericErrorMessage
()
when
(
ex
)
{
is
RocketChatAuthException
->
{
logout
()
}
else
->
{
Timber
.
d
(
ex
,
"Error loading my information for navheader"
)
ex
.
message
?.
let
{
view
.
showMessage
(
it
)
}.
ifNull
{
view
.
showGenericErrorMessage
()
}
}
}
}
}
...
...
@@ -83,17 +91,25 @@ class MainPresenter @Inject constructor(
try
{
clearTokens
()
client
.
logout
()
disconnect
()
removeAccountInterector
.
remove
(
currentServer
)
tokenRepository
.
remove
(
currentServer
)
navigator
.
toNewServer
()
}
catch
(
exception
:
RocketChatException
)
{
Timber
.
d
(
exception
,
"Error calling logout"
)
exception
.
message
?.
let
{
view
.
showMessage
(
it
)
}.
ifNull
{
view
.
showGenericErrorMessage
()
}
}
try
{
disconnect
()
removeAccountInterector
.
remove
(
currentServer
)
tokenRepository
.
remove
(
currentServer
)
navigator
.
toNewServer
()
}
catch
(
ex
:
Exception
)
{
Timber
.
d
(
ex
,
"Error cleaning up the session..."
)
}
navigator
.
toNewServer
()
}
}
...
...
@@ -102,7 +118,6 @@ class MainPresenter @Inject constructor(
val
pushToken
=
localRepository
.
get
(
LocalRepository
.
KEY_PUSH_TOKEN
)
if
(
pushToken
!=
null
)
{
client
.
unregisterPushToken
(
pushToken
)
localRepository
.
clear
(
LocalRepository
.
KEY_PUSH_TOKEN
)
}
localRepository
.
clearAllFromServer
(
currentServer
)
}
...
...
app/src/main/java/chat/rocket/android/main/viewmodel/NavHeaderViewModelMapper.kt
View file @
05e29725
...
...
@@ -7,16 +7,16 @@ import javax.inject.Inject
class
NavHeaderViewModelMapper
@Inject
constructor
(
serverInteractor
:
GetCurrentServerInteractor
,
getSettingsInteractor
:
GetSettingsInteractor
)
{
private
va
r
settings
:
PublicSettings
=
getSettingsInteractor
.
get
(
serverInteractor
.
get
()
!!
)
private
va
l
baseUrl
=
settings
.
baseUrl
()
!!
private
va
l
currentServer
=
serverInteractor
.
get
()
!!
private
va
r
settings
:
PublicSettings
=
getSettingsInteractor
.
get
(
currentServer
)
fun
mapToViewModel
(
me
:
Myself
):
NavHeaderViewModel
{
val
username
=
mapUsername
(
me
)
val
thumb
=
me
.
username
?.
let
{
UrlHelper
.
getAvatarUrl
(
baseUrl
,
it
)
}
val
thumb
=
me
.
username
?.
let
{
UrlHelper
.
getAvatarUrl
(
currentServer
,
it
)
}
val
image
=
settings
.
wideTile
()
?:
settings
.
faviconLarge
()
val
logo
=
image
?.
let
{
UrlHelper
.
getServerLogoUrl
(
baseUrl
,
it
)
}
val
logo
=
image
?.
let
{
UrlHelper
.
getServerLogoUrl
(
currentServer
,
it
)
}
return
NavHeaderViewModel
(
username
,
baseUrl
,
thumb
,
logo
)
return
NavHeaderViewModel
(
username
,
currentServer
,
thumb
,
logo
)
}
private
fun
mapUsername
(
me
:
Myself
):
String
{
...
...
app/src/main/java/chat/rocket/android/server/domain/SettingsRepository.kt
View file @
05e29725
...
...
@@ -95,5 +95,5 @@ fun PublicSettings.uploadMaxFileSize(): Int {
return
this
[
UPLOAD_MAX_FILE_SIZE
]
?.
value
?.
let
{
it
as
Int
}
?:
Int
.
MAX_VALUE
}
fun
PublicSettings
.
baseUrl
():
String
?
=
this
[
SITE_URL
]
?.
value
as
String
fun
PublicSettings
.
baseUrl
():
String
?
=
this
[
SITE_URL
]
?.
value
as
String
?
fun
PublicSettings
.
siteName
():
String
?
=
this
[
SITE_NAME
]
?.
value
as
String
?
\ 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