#1546 Only https custom server url

This commit is contained in:
sictiru 2021-10-04 21:55:33 -07:00
parent f9029042eb
commit ea783a8182
2 changed files with 8 additions and 2 deletions

View file

@ -14,7 +14,8 @@
<string name="login_logged_in">Logged in!</string>
<string name="login_retrieving_feeds">Retrieving feeds…</string>
<string name="login_next">Next</string>
<string name="login_custom_server_scheme_error">Expected \'https://\' custom server URL</string>
<string name="search_for_feed">Search for feeds</string>
<string name="loading">Loading…</string>

View file

@ -9,6 +9,7 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.inputmethod.EditorInfo
import android.widget.Toast
import androidx.fragment.app.Fragment
import com.newsblur.R
import com.newsblur.activity.LoginProgress
@ -61,10 +62,14 @@ class LoginRegisterFragment : Fragment() {
if (!TextUtils.isEmpty(binding.loginUsername.text.toString())) {
// set the custom server endpoint before any API access, even the cookie fetch.
val customServerValue = binding.loginCustomServerValue.text.toString()
if (!TextUtils.isEmpty(customServerValue)) {
if (!TextUtils.isEmpty(customServerValue) && customServerValue.startsWith("https://")) {
APIConstants.setCustomServer(customServerValue)
PrefsUtils.saveCustomServer(activity, customServerValue)
} else if (!TextUtils.isEmpty(customServerValue)) {
Toast.makeText(requireActivity(), R.string.login_custom_server_scheme_error, Toast.LENGTH_LONG).show()
return
}
val loginIntent = Intent(activity, LoginProgress::class.java).apply {
putExtra("username", binding.loginUsername.text.toString())
putExtra("password", binding.loginPassword.text.toString())