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
a62ab7fe
Unverified
Commit
a62ab7fe
authored
Mar 29, 2018
by
Lucio Maciel
Committed by
GitHub
Mar 29, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #966 from RocketChat/new/login-with-github
[NEW] Login with GitHub (OAuth).
parents
e797d903
30eec406
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
15 deletions
+13
-15
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+1
-1
LoginPresenter.kt
...droid/authentication/login/presentation/LoginPresenter.kt
+2
-3
LoginFragment.kt
...t/rocket/android/authentication/login/ui/LoginFragment.kt
+6
-7
OauthWebViewActivity.kt
...t/rocket/android/webview/oauth/ui/OauthWebViewActivity.kt
+4
-4
No files found.
app/src/main/AndroidManifest.xml
View file @
a62ab7fe
...
...
@@ -55,7 +55,7 @@
android:theme=
"@style/AppTheme"
/>
<activity
android:name=
".webview.
gitlab.ui.Gitlab
WebViewActivity"
android:name=
".webview.
oauth.ui.Oauth
WebViewActivity"
android:windowSoftInputMode=
"adjustResize|stateAlwaysHidden"
android:theme=
"@style/AppTheme"
/>
...
...
app/src/main/java/chat/rocket/android/authentication/login/presentation/LoginPresenter.kt
View file @
a62ab7fe
...
...
@@ -115,6 +115,8 @@ class LoginPresenter @Inject constructor(private val view: LoginView,
launchUI
(
strategy
)
{
try
{
val
services
=
client
.
settingsOauth
().
services
val
state
=
"{\"loginStyle\":\"popup\",\"credentialToken\":\"${generateRandomString(40)}\",\"isCordova\":true}"
.
encodeToBase64
()
if
(
services
.
isNotEmpty
())
{
var
totalSocialAccountsEnabled
=
0
...
...
@@ -125,7 +127,6 @@ class LoginPresenter @Inject constructor(private val view: LoginView,
if
(
settings
.
isGithubAuthenticationEnabled
())
{
val
clientId
=
getOauthClientId
(
services
,
SERVICE_NAME_GITHUB
)
if
(
clientId
!=
null
)
{
val
state
=
generateRandomString
(
5
)
view
.
setupGithubButtonListener
(
UrlHelper
.
getGithubOauthUrl
(
clientId
,
state
),
state
)
view
.
enableLoginByGithub
()
totalSocialAccountsEnabled
++
...
...
@@ -150,8 +151,6 @@ class LoginPresenter @Inject constructor(private val view: LoginView,
if
(
settings
.
isGitlabAuthenticationEnabled
())
{
val
clientId
=
getOauthClientId
(
services
,
SERVICE_NAME_GILAB
)
if
(
clientId
!=
null
)
{
// TODO: Improve this code.
val
state
=
"{\"loginStyle\":\"popup\",\"credentialToken\":\"${generateRandomString(40)}\",\"isCordova\":true}"
.
encodeToBase64
()
view
.
setupGitlabButtonListener
(
UrlHelper
.
getGitlabOauthUrl
(
clientId
,
currentServer
,
state
),
state
)
view
.
enableLoginByGitlab
()
totalSocialAccountsEnabled
++
...
...
app/src/main/java/chat/rocket/android/authentication/login/ui/LoginFragment.kt
View file @
a62ab7fe
...
...
@@ -21,9 +21,9 @@ import chat.rocket.android.helper.TextHelper
import
chat.rocket.android.util.extensions.*
import
chat.rocket.android.webview.cas.ui.INTENT_CAS_TOKEN
import
chat.rocket.android.webview.cas.ui.casWebViewIntent
import
chat.rocket.android.webview.
gitlab
.ui.INTENT_OAUTH_CREDENTIAL_SECRET
import
chat.rocket.android.webview.
gitlab
.ui.INTENT_OAUTH_CREDENTIAL_TOKEN
import
chat.rocket.android.webview.
gitlab.ui.gitlab
WebViewIntent
import
chat.rocket.android.webview.
oauth
.ui.INTENT_OAUTH_CREDENTIAL_SECRET
import
chat.rocket.android.webview.
oauth
.ui.INTENT_OAUTH_CREDENTIAL_TOKEN
import
chat.rocket.android.webview.
oauth.ui.oauth
WebViewIntent
import
dagger.android.support.AndroidSupportInjection
import
kotlinx.android.synthetic.main.fragment_authentication_log_in.*
import
javax.inject.Inject
...
...
@@ -210,9 +210,8 @@ class LoginFragment : Fragment(), LoginView {
override
fun
setupGithubButtonListener
(
githubUrl
:
String
,
state
:
String
)
{
button_github
.
setOnClickListener
{
// TODO
// startActivityForResult(context?.githubWebViewIntent(url, state), REQUEST_CODE_FOR_OAUTH)
// activity?.overridePendingTransition(R.anim.slide_up, R.anim.hold)
startActivityForResult
(
context
?.
oauthWebViewIntent
(
githubUrl
,
state
),
REQUEST_CODE_FOR_OAUTH
)
activity
?.
overridePendingTransition
(
R
.
anim
.
slide_up
,
R
.
anim
.
hold
)
}
}
...
...
@@ -238,7 +237,7 @@ class LoginFragment : Fragment(), LoginView {
override
fun
setupGitlabButtonListener
(
gitlabUrl
:
String
,
state
:
String
)
{
button_gitlab
.
setOnClickListener
{
startActivityForResult
(
context
?.
gitlab
WebViewIntent
(
gitlabUrl
,
state
),
REQUEST_CODE_FOR_OAUTH
)
startActivityForResult
(
context
?.
oauth
WebViewIntent
(
gitlabUrl
,
state
),
REQUEST_CODE_FOR_OAUTH
)
activity
?.
overridePendingTransition
(
R
.
anim
.
slide_up
,
R
.
anim
.
hold
)
}
}
...
...
app/src/main/java/chat/rocket/android/webview/
gitlab/ui/Gitlab
WebViewActivity.kt
→
app/src/main/java/chat/rocket/android/webview/
oauth/ui/Oauth
WebViewActivity.kt
View file @
a62ab7fe
package
chat.rocket.android.webview.
gitlab
.ui
package
chat.rocket.android.webview.
oauth
.ui
import
android.annotation.SuppressLint
import
android.app.Activity
...
...
@@ -16,8 +16,8 @@ import kotlinx.android.synthetic.main.activity_web_view.*
import
kotlinx.android.synthetic.main.app_bar.*
import
org.json.JSONObject
fun
Context
.
gitlab
WebViewIntent
(
webPageUrl
:
String
,
state
:
String
):
Intent
{
return
Intent
(
this
,
Gitlab
WebViewActivity
::
class
.
java
).
apply
{
fun
Context
.
oauth
WebViewIntent
(
webPageUrl
:
String
,
state
:
String
):
Intent
{
return
Intent
(
this
,
Oauth
WebViewActivity
::
class
.
java
).
apply
{
putExtra
(
INTENT_WEB_PAGE_URL
,
webPageUrl
)
putExtra
(
INTENT_STATE
,
state
)
}
...
...
@@ -31,7 +31,7 @@ const val INTENT_OAUTH_CREDENTIAL_TOKEN = "credential_token"
const
val
INTENT_OAUTH_CREDENTIAL_SECRET
=
"credential_secret"
// Shows a WebView to the user authenticate with your Gitlab credentials.
class
Gitlab
WebViewActivity
:
AppCompatActivity
()
{
class
Oauth
WebViewActivity
:
AppCompatActivity
()
{
private
lateinit
var
webPageUrl
:
String
private
lateinit
var
state
:
String
...
...
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