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
9f2c01e8
Commit
9f2c01e8
authored
Dec 22, 2017
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add TODOs and update field validations.
parent
c9399aa4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
14 deletions
+11
-14
LoginPresenter.kt
...droid/authentication/login/presentation/LoginPresenter.kt
+11
-14
No files found.
app/src/main/java/chat/rocket/android/authentication/login/presentation/LoginPresenter.kt
View file @
9f2c01e8
...
@@ -21,6 +21,7 @@ class LoginPresenter @Inject constructor(private val view: LoginView,
...
@@ -21,6 +21,7 @@ class LoginPresenter @Inject constructor(private val view: LoginView,
private
val
okHttpClient
:
OkHttpClient
,
private
val
okHttpClient
:
OkHttpClient
,
private
val
logger
:
PlatformLogger
,
private
val
logger
:
PlatformLogger
,
private
val
repository
:
AuthTokenRepository
)
{
private
val
repository
:
AuthTokenRepository
)
{
// TODO: Create a single entry point to RocketChatClient
val
client
:
RocketChatClient
=
RocketChatClient
.
create
{
val
client
:
RocketChatClient
=
RocketChatClient
.
create
{
httpClient
=
okHttpClient
httpClient
=
okHttpClient
restUrl
=
HttpUrl
.
parse
(
navigator
.
currentServer
)
!!
restUrl
=
HttpUrl
.
parse
(
navigator
.
currentServer
)
!!
...
@@ -29,26 +30,22 @@ class LoginPresenter @Inject constructor(private val view: LoginView,
...
@@ -29,26 +30,22 @@ class LoginPresenter @Inject constructor(private val view: LoginView,
platformLogger
=
logger
platformLogger
=
logger
}
}
fun
authenticate
(
usernameOrEmail
:
EditText
,
password
:
EditText
)
{
fun
authenticate
(
usernameOrEmail
EditText
:
EditText
,
passwordEditText
:
EditText
)
{
val
user
=
usernameOrEmail
.
textContent
val
user
nameOrEmail
=
usernameOrEmailEditText
.
textContent
val
pass
=
password
.
textContent
val
pass
word
=
passwordEditText
.
textContent
if
(
user
.
isBlank
()
&&
pass
.
isEmpty
())
{
when
{
view
.
shakeView
(
usernameOrEmail
)
usernameOrEmail
.
isBlank
()
->
view
.
shakeView
(
usernameOrEmailEditText
)
view
.
shakeView
(
password
)
password
.
isEmpty
()
->
view
.
shakeView
(
passwordEditText
)
}
else
if
(
user
.
isBlank
())
{
else
->
launchUI
(
strategy
)
{
view
.
shakeView
(
usernameOrEmail
)
}
else
if
(
pass
.
isEmpty
())
{
view
.
shakeView
(
password
)
}
else
{
launchUI
(
strategy
)
{
view
.
showLoading
()
view
.
showLoading
()
try
{
try
{
val
token
=
client
.
login
(
user
,
pass
)
val
token
=
client
.
login
(
usernameOrEmail
,
password
)
// TODO: Salve token.
navigator
.
toChatList
()
navigator
.
toChatList
()
}
catch
(
ex
:
RocketChatException
)
{
}
catch
(
ex
:
RocketChatException
)
{
when
(
ex
)
{
when
(
ex
)
{
is
RocketChatTwoFactorException
->
navigator
.
toTwoFA
(
navigator
.
currentServer
!!
,
user
,
pass
)
is
RocketChatTwoFactorException
->
navigator
.
toTwoFA
(
navigator
.
currentServer
!!
,
user
nameOrEmail
,
password
)
else
->
{
else
->
{
val
errorMessage
=
ex
.
message
val
errorMessage
=
ex
.
message
if
(
errorMessage
!=
null
)
{
if
(
errorMessage
!=
null
)
{
...
...
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