Commit f4c434e2 authored by aniket's avatar aniket

minor fixes

parent e528cdf2
......@@ -55,6 +55,7 @@ class LoginPresenter @Inject constructor(
private lateinit var credentialSecret: String
private lateinit var deepLinkUserId: String
private lateinit var deepLinkToken: String
private var loginCredentials: Credential? = null
fun setupView() {
setupConnectionInfo(currentServer)
......@@ -304,10 +305,12 @@ class LoginPresenter @Inject constructor(
saveAccount(username)
saveToken(token)
registerPushToken()
var loginCredentials: Credential = Credential.Builder(usernameOrEmail)
.setPassword(password)
.build()
view.saveSmartLockCredentials(loginCredentials)
if (loginType == TYPE_LOGIN_USER_EMAIL) {
loginCredentials = Credential.Builder(usernameOrEmail)
.setPassword(password)
.build()
view.saveSmartLockCredentials(loginCredentials)
}
navigator.toChatList()
} else if (loginType == TYPE_LOGIN_OAUTH) {
navigator.toRegisterUsername(token.userId, token.authToken)
......
......@@ -57,6 +57,7 @@ class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks
private val layoutListener = ViewTreeObserver.OnGlobalLayoutListener {
areLoginOptionsNeeded()
}
private var isOauthSuccessful = false
private var isGlobalLayoutListenerSetUp = false
private var deepLinkInfo: LoginDeepLinkInfo? = null
private var credentialsToBeSaved: Credential? = null
......@@ -122,6 +123,7 @@ class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks
presenter.authenticateWithCas(getStringExtra(INTENT_CAS_TOKEN))
}
} else if (requestCode == REQUEST_CODE_FOR_OAUTH) {
isOauthSuccessful = true
data?.apply {
presenter.authenticateWithOauth(
getStringExtra(INTENT_OAUTH_CREDENTIAL_TOKEN),
......@@ -147,20 +149,12 @@ class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks
} else if (requestCode == MULTIPLE_CREDENTIALS_READ) {
Log.d("STATUS", "failed ")
}
//cancel button pressed by the user in case of reading from smart lock
else if (resultCode == Activity.RESULT_CANCELED) {
//add shared preference so that the dialog is not shown always
}
//create new account to use it as login account (deal with this case carefully, many edge cases)
else if (resultCode == CredentialsApi.ACTIVITY_RESULT_ADD_ACCOUNT) {
else if (resultCode == Activity.RESULT_CANCELED && requestCode == REQUEST_CODE_FOR_OAUTH) {
Log.d("returned", "from oauth")
}
//no hints for user id's exist
else if (resultCode == CredentialsApi.ACTIVITY_RESULT_NO_HINTS_AVAILABLE) {
} else {
Log.d("Status", "nothing happening")
}
}
......@@ -182,14 +176,14 @@ class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks
override fun onStart() {
super.onStart()
requestCredentials()
if (!isOauthSuccessful) {
requestCredentials()
}
}
private fun requestCredentials() {
var request: CredentialRequest = CredentialRequest.Builder()
.setPasswordLoginSupported(true)
//add account types for custom login methods
/*.setAccountTypes(IdentityProviders.GOOGLE,IdentityProviders.FACEBOOK)*/
.build()
Auth.CredentialsApi.request(googleApiClient, request).setResultCallback { credentialRequestResult ->
......@@ -224,14 +218,6 @@ class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks
private fun handleCredential(loginCredentials: Credential) {
if (loginCredentials.accountType == null) {
presenter.authenticateWithUserAndPassword(loginCredentials.id, loginCredentials.password!!)
} else if (loginCredentials.accountType == IdentityProviders.GOOGLE) {
//TODO add SL code for google as custom login method
} else if (loginCredentials.accountType == IdentityProviders.FACEBOOK) {
//TODO add SL code for facebook as custom login method
} else if (loginCredentials.accountType == IdentityProviders.TWITTER) {
//TODO add SL code for twitter as custom login method
} else if (loginCredentials.accountType == IdentityProviders.LINKEDIN) {
//TODO add SL code for linkedin as custom login method
}
}
......
......@@ -40,7 +40,6 @@ class OauthWebViewActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_web_view)
webPageUrl = intent.getStringExtra(INTENT_WEB_PAGE_URL)
requireNotNull(webPageUrl) { "no web_page_url provided in Intent extras" }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment