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
7b0dda78
Unverified
Commit
7b0dda78
authored
Mar 29, 2018
by
Filipe de Lima Brito
Committed by
GitHub
Mar 29, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop-2.x' into lang-hindi
parents
07ac0274
40fc6074
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
2 deletions
+35
-2
LoginPresenter.kt
...droid/authentication/login/presentation/LoginPresenter.kt
+7
-2
LoginView.kt
...et/android/authentication/login/presentation/LoginView.kt
+10
-0
LoginFragment.kt
...t/rocket/android/authentication/login/ui/LoginFragment.kt
+7
-0
UrlHelper.kt
app/src/main/java/chat/rocket/android/helper/UrlHelper.kt
+11
-0
No files found.
app/src/main/java/chat/rocket/android/authentication/login/presentation/LoginPresenter.kt
View file @
7b0dda78
...
...
@@ -30,6 +30,7 @@ private const val TYPE_LOGIN_CAS = 1
private
const
val
TYPE_LOGIN_OAUTH
=
2
private
const
val
SERVICE_NAME_GITHUB
=
"github"
private
const
val
SERVICE_NAME_GOOGLE
=
"google"
private
const
val
SERVICE_NAME_LINKEDIN
=
"linkedin"
private
const
val
SERVICE_NAME_GILAB
=
"gitlab"
class
LoginPresenter
@Inject
constructor
(
private
val
view
:
LoginView
,
...
...
@@ -142,9 +143,13 @@ class LoginPresenter @Inject constructor(private val view: LoginView,
}
}
if
(
settings
.
isLinkedinAuthenticationEnabled
())
{
val
clientId
=
getOauthClientId
(
services
,
SERVICE_NAME_LINKEDIN
)
if
(
clientId
!=
null
)
{
view
.
setupGoogleButtonListener
(
UrlHelper
.
getLinkedinOauthUrl
(
clientId
,
currentServer
,
state
),
state
)
view
.
enableLoginByLinkedin
()
totalSocialAccountsEnabled
++
}
}
if
(
settings
.
isMeteorAuthenticationEnabled
())
{
view
.
enableLoginByMeteor
()
totalSocialAccountsEnabled
++
...
...
app/src/main/java/chat/rocket/android/authentication/login/presentation/LoginView.kt
View file @
7b0dda78
...
...
@@ -132,9 +132,19 @@ interface LoginView : LoadingView, MessageView, InternetView {
/**
* Shows the "login by Linkedin" view if it is enable by the server settings.
*
* REMARK: We must set up the Linkedin button listener before enabling it [setupLinkedinButtonListener].
*/
fun
enableLoginByLinkedin
()
/**
* Setups the Linkedin button when tapped.
*
* @param linkedinUrl The Linkedin OAuth URL to authenticate with.
* @param state A random string generated by the app, which you'll verify later (to protect against forgery attacks).
*/
fun
setupLinkedinButtonListener
(
linkedinUrl
:
String
,
state
:
String
)
/**
* Shows the "login by Meteor" view if it is enable by the server settings.
*/
...
...
app/src/main/java/chat/rocket/android/authentication/login/ui/LoginFragment.kt
View file @
7b0dda78
...
...
@@ -231,6 +231,13 @@ class LoginFragment : Fragment(), LoginView {
button_linkedin
.
isClickable
=
true
}
override
fun
setupLinkedinButtonListener
(
linkedinUrl
:
String
,
state
:
String
)
{
button_linkedin
.
setOnClickListener
{
startActivityForResult
(
context
?.
oauthWebViewIntent
(
linkedinUrl
,
state
),
REQUEST_CODE_FOR_OAUTH
)
activity
?.
overridePendingTransition
(
R
.
anim
.
slide_up
,
R
.
anim
.
hold
)
}
}
override
fun
enableLoginByMeteor
()
{
button_meteor
.
isClickable
=
true
}
...
...
app/src/main/java/chat/rocket/android/helper/UrlHelper.kt
View file @
7b0dda78
...
...
@@ -56,6 +56,17 @@ object UrlHelper {
fun
getGoogleOauthUrl
(
clientId
:
String
,
serverUrl
:
String
,
state
:
String
)
=
"https://accounts.google.com/o/oauth2/v2/auth?client_id=$clientId&redirect_uri=${removeTrailingSlash(serverUrl)}/_oauth/google?close&response_type=code&state=$state&scope=email%20profile"
/**
* Returns the Linkedin Oauth URL.
*
* @param clientId The Linkedin client ID.
* @param serverUrl The server URL.
* @param state An unguessable random string used to protect against forgery attacks.
* @return The Linkedin Oauth URL.
*/
fun
getLinkedinOauthUrl
(
clientId
:
String
,
serverUrl
:
String
,
state
:
String
)
=
"https://www.linkedin.com/oauth/v2/authorization?response_type=code&client_id=$clientId&redirect_uri=${removeTrailingSlash(serverUrl)}/_oauth/linkedin?close&state=$state"
/**
* Returns the Gitlab Oauth URL.
*
...
...
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