Android log-in: the server filled in, changed behind a button

1274cd6 · gmorell · 2026-12-03 18:14

27 files +335 -53
Message
{commit_body(@commit)}

Files changed

modified android/app/src/main/java/org/neiam/cartosnap/app/auth/login/HelpScreen.kt
+6 −32
@@ -42,11 +42,8 @@ fun HelpScreen(
42 42 pairLocation: String,
43 43 server: String,
44 44 methods: AuthMethods?,
45 − onChangeServer: (String) -> Unit,
46 45 onClose: () -> Unit,
47 46 ) {
48 − var editing by remember { mutableStateOf(false) }
49 −
50 47 Scaffold(
51 48 topBar = {
52 49 TopAppBar(
@@ -95,41 +92,18 @@ fun HelpScreen(
95 92 methods?.username?.reason?.let { Para("Right now: $it") }
96 93
97 94 Section("Server")
98 − Para(server)
99 − TextButton(onClick = { editing = true }) { Text("Change server") }
95 + Para(ServerChoice.host(server))
96 + Para(
97 + "This app signs in to the server above. To use another one, open " +
98 + "${methods?.oidcLabel ?: "the single sign-on sheet"} or Username and tap Change " +
99 + "next to the server; Reset to default goes back to this app's usual one.",
100 + )
100 101 Para(
101 102 "Signing out, or revoking this phone under connected devices on the website, " +
102 103 "removes its access.",
103 104 )
104 105 }
105 106 }
106 −
107 − if (editing) {
108 − var value by remember { mutableStateOf(server) }
109 − AlertDialog(
110 − onDismissRequest = { editing = false },
111 − title = { Text("Server") },
112 − text = {
113 − OutlinedTextField(
114 − value = value,
115 − onValueChange = { value = it },
116 − singleLine = true,
117 − label = { Text("Address") },
118 − keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Uri),
119 − modifier = Modifier.fillMaxWidth(),
120 − )
121 − },
122 − confirmButton = {
123 − TextButton(
124 − onClick = {
125 − if (value.isNotBlank()) onChangeServer(value)
126 − editing = false
127 − },
128 − ) { Text("Use") }
129 − },
130 − dismissButton = { TextButton(onClick = { editing = false }) { Text("Cancel") } },
131 − )
132 − }
133 107 }
134 108
135 109 @Composable
modified android/app/src/main/java/org/neiam/cartosnap/app/auth/login/LoginFlows.kt
+25 −3
@@ -18,7 +18,14 @@ class LoginFlows(
18 18 val prefs: LoginPrefs,
19 19 val api: LoginApi = LoginApi(),
20 20 ) {
21 − val server: String get() = prefs.server(host.defaultServer)
21 + private val _server = MutableStateFlow(prefs.server(host.defaultServer))
22 +
23 + /** The server in use, shared by the page, the OIDC and the Username sheets. */
24 + val serverState: StateFlow<String> = _server.asStateFlow()
25 + val server: String get() = _server.value
26 +
27 + /** The build's default server (its production host). */
28 + val defaultServer: String get() = LoginPrefs.normalizeServer(host.defaultServer)
22 29
23 30 private val _requestedSheet = MutableStateFlow<LoginSheet?>(null)
24 31
@@ -29,14 +36,29 @@ class LoginFlows(
29 36 _requestedSheet.value = sheet
30 37 }
31 38
32 − fun setServer(server: String) = prefs.setServer(server)
39 + fun setServer(server: String) {
40 + prefs.setServer(server)
41 + _server.value = LoginPrefs.normalizeServer(server)
42 + }
43 +
44 + /**
45 + * The user's edit of the server: applied when it is a server address,
46 + * otherwise the server in use stays and the error says why.
47 + */
48 + fun changeServer(input: String): ServerChoice.Edit =
49 + ServerChoice.edit(server, input).also { if (it.error == null) setServer(it.server) }
50 +
51 + fun resetServer() {
52 + prefs.clearServer()
53 + _server.value = defaultServer
54 + }
33 55
34 56 suspend fun methods(): AuthMethods = api.methods(server)
35 57
36 58 /** Stores the token like pairing does, and remembers the server it belongs to. */
37 59 fun keep(server: String, result: SignedIn) {
38 60 host.save(server, result.token)
39 − prefs.setServer(server)
61 + setServer(server)
40 62 result.email?.let { prefs.lastEmail = it }
41 63 }
42 64
modified android/app/src/main/java/org/neiam/cartosnap/app/auth/login/LoginHost.kt
+54 −1
@@ -59,12 +59,18 @@ fun deviceName(): String {
59 59 class LoginPrefs(context: Context) {
60 60 private val prefs = context.getSharedPreferences("login_prefs", Context.MODE_PRIVATE)
61 61
62 − fun server(default: String): String = prefs.getString(KEY_SERVER, null) ?: default
62 + /** The last server used, else the build's default (`ServerChoice.initial`). */
63 + fun server(default: String): String = ServerChoice.initial(prefs.getString(KEY_SERVER, null), default)
63 64
64 65 fun setServer(server: String) {
65 66 prefs.edit().putString(KEY_SERVER, normalizeServer(server)).apply()
66 67 }
67 68
69 + /** Back to the build's default: forget the chosen server. */
70 + fun clearServer() {
71 + prefs.edit().remove(KEY_SERVER).apply()
72 + }
73 +
68 74 var lastEmail: String?
69 75 get() = prefs.getString(KEY_EMAIL, null)
70 76 set(v) = prefs.edit().putString(KEY_EMAIL, v).apply()
@@ -107,3 +113,50 @@ class LoginPrefs(context: Context) {
107 113 normalizeServer(a).lowercase() == normalizeServer(b).lowercase()
108 114 }
109 115 }
116 +
117 +/**
118 + * Which server the log-in page talks to. The build's default (its
119 + * production host, `BuildConfig.DEFAULT_SERVER`) unless the user picked
120 + * another, which is remembered; an edit that isn't a server address keeps
121 + * the one in use and says why.
122 + */
123 +object ServerChoice {
124 + data class Edit(val server: String, val error: String?)
125 +
126 + const val INVALID = "That isn't a server address. Enter one like app.example.org."
127 +
128 + /** The saved server if it is still a valid one, else the default. */
129 + fun initial(saved: String?, default: String): String =
130 + saved?.let(::parse) ?: LoginPrefs.normalizeServer(default)
131 +
132 + /**
133 + * `app.example.org`, `https://app.example.org/` or `http://10.0.2.2:4000`
134 + * → `https://app.example.org` (no trailing slash); null for anything that
135 + * isn't a bare http(s) server address (no path, query, user or spaces).
136 + */
137 + fun parse(raw: String): String? {
138 + val t = raw.trim()
139 + if (t.isEmpty() || t.any { it.isWhitespace() }) return null
140 + val normalized = LoginPrefs.normalizeServer(t)
141 + val uri = runCatching { java.net.URI(normalized) }.getOrNull() ?: return null
142 + val scheme = uri.scheme?.lowercase()
143 + if (scheme != "https" && scheme != "http") return null
144 + val host = uri.host ?: return null
145 + if (host.isBlank() || !host.contains('.') && host != "localhost") return null
146 + if (uri.rawUserInfo != null || uri.rawQuery != null || uri.rawFragment != null) return null
147 + if (!uri.rawPath.isNullOrEmpty() && uri.rawPath != "/") return null
148 + val port = if (uri.port > 0) ":${uri.port}" else ""
149 + return "$scheme://${host.lowercase()}$port"
150 + }
151 +
152 + /** The result of the user's edit: the new server, or the current one and an error. */
153 + fun edit(current: String, input: String): Edit =
154 + parse(input)?.let { Edit(it, null) } ?: Edit(current, INVALID)
155 +
156 + fun isDefault(current: String, default: String): Boolean =
157 + LoginPrefs.sameServer(current, default)
158 +
159 + /** `https://app.example.org` → `app.example.org`, for showing. */
160 + fun host(server: String): String =
161 + server.substringAfter("://").trimEnd('/')
162 +}
modified android/app/src/main/java/org/neiam/cartosnap/app/auth/login/LoginScreen.kt
+46 −13
@@ -27,7 +27,9 @@ import androidx.compose.material3.ModalBottomSheet
27 27 import androidx.compose.material3.Surface
28 28 import androidx.compose.material3.Text
29 29 import androidx.compose.material3.TextButton
30 +import androidx.compose.material3.SheetValue
30 31 import androidx.compose.material3.rememberModalBottomSheetState
32 +import androidx.compose.runtime.rememberUpdatedState
31 33 import androidx.compose.runtime.Composable
32 34 import androidx.compose.runtime.LaunchedEffect
33 35 import androidx.compose.runtime.collectAsState
@@ -68,7 +70,9 @@ fun LoginScreen(
68 70 ) {
69 71 var showHelp by rememberSaveable { mutableStateOf(false) }
70 72 var sheet by rememberSaveable { mutableStateOf<LoginSheet?>(null) }
71 − var server by remember { mutableStateOf(flows.server) }
73 + var editingServer by rememberSaveable { mutableStateOf(false) }
74 + // The last server used, else the build's default: methods load at once.
75 + val server by flows.serverState.collectAsState()
72 76 var reload by remember { mutableIntStateOf(0) }
73 77 var methods by remember { mutableStateOf<AuthMethods?>(null) }
74 78 var loadError by remember { mutableStateOf<String?>(null) }
@@ -104,10 +108,6 @@ fun LoginScreen(
104 108 pairLocation = flows.host.pairLocation,
105 109 server = server,
106 110 methods = methods,
107 − onChangeServer = {
108 − flows.setServer(it)
109 − server = flows.server
110 − },
111 111 onClose = { showHelp = false },
112 112 )
113 113 return
@@ -124,6 +124,9 @@ fun LoginScreen(
124 124 val compactHeight = maxHeight < 420.dp
125 125 val narrowHeader = maxWidth * HEADER_WEIGHT < 200.dp
126 126
127 + // Unreachable server: OIDC and Username still open, since their
128 + // sheets are where the server is changed.
129 + val reachable = loadError == null
127 130 val buttons: @Composable (Modifier) -> Unit = { mod ->
128 131 MethodButton(
129 132 title = "Pair",
@@ -138,7 +141,7 @@ fun LoginScreen(
138 141 title = "OIDC",
139 142 description = m.oidcLabel,
140 143 icon = Icons.Default.Key,
141 − method = m.oidc,
144 + method = if (reachable) m.oidc else AuthMethods.Method(true),
142 145 compact = compactHeight,
143 146 modifier = mod,
144 147 onClick = { sheet = LoginSheet.Oidc },
@@ -151,7 +154,7 @@ fun LoginScreen(
151 154 else -> "Email me a sign-in link"
152 155 },
153 156 icon = Icons.Default.Person,
154 − method = m.username,
157 + method = if (reachable) m.username else AuthMethods.Method(true),
155 158 compact = compactHeight,
156 159 modifier = mod,
157 160 onClick = { sheet = LoginSheet.Username },
@@ -193,11 +196,29 @@ fun LoginScreen(
193 196 }
194 197
195 198 sheet?.let { which ->
196 − LoginSheetHost(onDismiss = { sheet = null }) {
199 + LoginSheetHost(
200 + onDismiss = { sheet = null; editingServer = false },
201 + // Back (or a swipe) while the server is being edited closes the
202 + // editor first, not the sheet.
203 + beforeHide = {
204 + if (editingServer) {
205 + editingServer = false
206 + false
207 + } else {
208 + true
209 + }
210 + },
211 + ) {
197 212 when (which) {
198 213 LoginSheet.Pair -> PairSheet(flows, onSignedIn = { sheet = null; onSignedIn() })
199 − LoginSheet.Oidc -> OidcSheet(flows, m, onDone = { sheet = null })
200 − LoginSheet.Username -> UsernameSheet(flows, m, onSignedIn = { sheet = null; onSignedIn() })
214 + LoginSheet.Oidc -> OidcSheet(
215 + flows, m, editingServer, { editingServer = it },
216 + onDone = { sheet = null },
217 + )
218 + LoginSheet.Username -> UsernameSheet(
219 + flows, m, editingServer, { editingServer = it },
220 + onSignedIn = { sheet = null; onSignedIn() },
221 + )
201 222 }
202 223 }
203 224 }
@@ -297,11 +318,23 @@ private fun MethodButton(
297 318 }
298 319 }
299 320
300 −/** A sheet that back and swipe-down close, back to the log-in page. */
321 +/**
322 + * A sheet that back and swipe-down close, back to the log-in page.
323 + * `beforeHide` may refuse (and do something else instead, e.g. close an
324 + * editor); Material 3 asks it before back, a swipe or a scrim tap hides.
325 + */
301 326 @OptIn(ExperimentalMaterial3Api::class)
302 327 @Composable
303 −private fun LoginSheetHost(onDismiss: () -> Unit, content: @Composable () -> Unit) {
304 − val state = rememberModalBottomSheetState(skipPartiallyExpanded = true)
328 +private fun LoginSheetHost(
329 + onDismiss: () -> Unit,
330 + beforeHide: () -> Boolean,
331 + content: @Composable () -> Unit,
332 +) {
333 + val currentBeforeHide by rememberUpdatedState(beforeHide)
334 + val state = rememberModalBottomSheetState(
335 + skipPartiallyExpanded = true,
336 + confirmValueChange = { it != SheetValue.Hidden || currentBeforeHide() },
337 + )
305 338 ModalBottomSheet(onDismissRequest = onDismiss, sheetState = state) {
306 339 content()
307 340 }
modified android/app/src/main/java/org/neiam/cartosnap/app/auth/login/Sheets.kt
+123 −2
@@ -2,6 +2,9 @@ package org.neiam.cartosnap.app.auth.login
2 2
3 3 import androidx.compose.foundation.layout.Arrangement
4 4 import androidx.compose.foundation.layout.Column
5 +import androidx.compose.foundation.layout.Row
6 +import androidx.compose.foundation.layout.FlowRow
7 +import androidx.compose.foundation.layout.ExperimentalLayoutApi
5 8 import androidx.compose.foundation.layout.Spacer
6 9 import androidx.compose.foundation.layout.fillMaxWidth
7 10 import androidx.compose.foundation.layout.height
@@ -19,6 +22,15 @@ import androidx.compose.material3.MaterialTheme
19 22 import androidx.compose.material3.OutlinedButton
20 23 import androidx.compose.material3.OutlinedTextField
21 24 import androidx.compose.material3.Text
25 +import androidx.compose.material3.TextButton
26 +import androidx.compose.runtime.collectAsState
27 +import androidx.compose.runtime.LaunchedEffect
28 +import androidx.compose.ui.Alignment
29 +import androidx.compose.ui.focus.FocusRequester
30 +import androidx.compose.ui.focus.focusRequester
31 +import androidx.compose.ui.semantics.contentDescription
32 +import androidx.compose.ui.text.TextRange
33 +import androidx.compose.ui.text.input.TextFieldValue
22 34 import androidx.compose.runtime.Composable
23 35 import androidx.compose.runtime.getValue
24 36 import androidx.compose.runtime.mutableStateOf
@@ -77,6 +89,97 @@ private fun Status(text: String?, error: Boolean) {
77 89
78 90 private val buttonHeight = Modifier.fillMaxWidth().sizeIn(minHeight = 48.dp)
79 91
92 +/**
93 + * The server the OIDC and Username sheets sign in to: shown as text (the
94 + * host large), with Change. Change opens an editor already filled in with
95 + * the server in use (not a hint), Use applies it, Reset to default goes back
96 + * to the build's server. An address that isn't one keeps the server in use
97 + * and says why. `editing` is the log-in page's, so back closes the editor
98 + * before the sheet.
99 + */
100 +@OptIn(ExperimentalLayoutApi::class)
101 +@Composable
102 +fun ServerRow(flows: LoginFlows, editing: Boolean, onEditingChange: (Boolean) -> Unit) {
103 + val server by flows.serverState.collectAsState()
104 + val isDefault = ServerChoice.isDefault(server, flows.defaultServer)
105 + var error by remember { mutableStateOf<String?>(null) }
106 +
107 + if (!editing) {
108 + Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth()) {
109 + Column(
110 + Modifier.weight(1f).semantics(mergeDescendants = true) {
111 + contentDescription = "Server: ${ServerChoice.host(server)}"
112 + },
113 + ) {
114 + Text(
115 + "Server",
116 + style = MaterialTheme.typography.labelMedium,
117 + color = MaterialTheme.colorScheme.onSurfaceVariant,
118 + )
119 + Text(ServerChoice.host(server), style = MaterialTheme.typography.titleMedium)
120 + if (!isDefault) {
121 + Text(
122 + "Not this app's usual server",
123 + style = MaterialTheme.typography.bodySmall,
124 + color = MaterialTheme.colorScheme.onSurfaceVariant,
125 + )
126 + }
127 + }
128 + TextButton(
129 + onClick = { error = null; onEditingChange(true) },
130 + modifier = Modifier.sizeIn(minHeight = 48.dp),
131 + ) { Text("Change") }
132 + }
133 + return
134 + }
135 +
136 + // Filled in with the server in use, cursor at the end, ready to edit.
137 + var value by remember {
138 + mutableStateOf(TextFieldValue(server, selection = TextRange(server.length)))
139 + }
140 + val focus = remember { FocusRequester() }
141 + LaunchedEffect(Unit) { focus.requestFocus() }
142 +
143 + fun use() {
144 + val result = flows.changeServer(value.text)
145 + error = result.error
146 + if (result.error == null) onEditingChange(false)
147 + }
148 +
149 + OutlinedTextField(
150 + value = value,
151 + onValueChange = { value = it; error = null },
152 + label = { Text("Server") },
153 + singleLine = true,
154 + isError = error != null,
155 + supportingText = error?.let { { Text(it) } },
156 + keyboardOptions = KeyboardOptions(
157 + keyboardType = KeyboardType.Uri,
158 + autoCorrect = false,
159 + imeAction = ImeAction.Done,
160 + ),
161 + keyboardActions = KeyboardActions(onDone = { use() }),
162 + modifier = Modifier.fillMaxWidth().focusRequester(focus),
163 + )
164 + FlowRow(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
165 + Button(onClick = ::use, modifier = Modifier.sizeIn(minHeight = 48.dp)) { Text("Use") }
166 + TextButton(
167 + onClick = { error = null; onEditingChange(false) },
168 + modifier = Modifier.sizeIn(minHeight = 48.dp),
169 + ) { Text("Cancel") }
170 + if (!isDefault) {
171 + TextButton(
172 + onClick = {
173 + flows.resetServer()
174 + error = null
175 + onEditingChange(false)
176 + },
177 + modifier = Modifier.sizeIn(minHeight = 48.dp),
178 + ) { Text("Reset to default (${ServerChoice.host(flows.defaultServer)})") }
179 + }
180 + }
181 +}
182 +
80 183 /**
81 184 * Pair: the existing pairing, unchanged. Settings → Connected devices on
82 185 * the web shows the server and a one-time code (`XK4F-9TQ2`); the app trades
@@ -159,11 +262,19 @@ fun PairSheet(flows: LoginFlows, onSignedIn: () -> Unit) {
159 262 * App Link, which the app trades for its device token.
160 263 */
161 264 @Composable
162 −fun OidcSheet(flows: LoginFlows, methods: AuthMethods, onDone: () -> Unit) {
265 +fun OidcSheet(
266 + flows: LoginFlows,
267 + methods: AuthMethods,
268 + editingServer: Boolean,
269 + onEditingServerChange: (Boolean) -> Unit,
270 + onDone: () -> Unit,
271 +) {
163 272 val context = LocalContext.current
164 273 var error by remember { mutableStateOf<String?>(null) }
165 274
166 275 SheetColumn(methods.oidcLabel) {
276 + ServerRow(flows, editingServer, onEditingServerChange)
277 + if (editingServer) return@SheetColumn
167 278 Text(
168 279 "Your browser opens the sign-in page. When you're done there, you come straight back here.",
169 280 style = MaterialTheme.typography.bodyMedium,
@@ -173,8 +284,10 @@ fun OidcSheet(flows: LoginFlows, methods: AuthMethods, onDone: () -> Unit) {
173 284 if (flows.startOidc(context, methods)) onDone()
174 285 else error = "No browser is available to sign in with."
175 286 },
287 + enabled = methods.oidc.enabled,
176 288 modifier = buttonHeight,
177 289 ) { Text("Continue to ${methods.oidcLabel.removePrefix("Sign in with ")}") }
290 + if (!methods.oidc.enabled) Status(methods.oidc.reason ?: "Not available on this server.", true)
178 291 Status(error, true)
179 292 }
180 293 }
@@ -185,7 +298,13 @@ fun OidcSheet(flows: LoginFlows, methods: AuthMethods, onDone: () -> Unit) {
185 298 */
186 299 @OptIn(ExperimentalComposeUiApi::class)
187 300 @Composable
188 −fun UsernameSheet(flows: LoginFlows, methods: AuthMethods, onSignedIn: () -> Unit) {
301 +fun UsernameSheet(
302 + flows: LoginFlows,
303 + methods: AuthMethods,
304 + editingServer: Boolean,
305 + onEditingServerChange: (Boolean) -> Unit,
306 + onSignedIn: () -> Unit,
307 +) {
189 308 val scope = rememberCoroutineScope()
190 309 var email by rememberSaveable { mutableStateOf(flows.prefs.lastEmail.orEmpty()) }
191 310 var password by remember { mutableStateOf("") }
@@ -228,6 +347,8 @@ fun UsernameSheet(flows: LoginFlows, methods: AuthMethods, onSignedIn: () -> Uni
228 347 }
229 348
230 349 SheetColumn("Sign in with your email") {
350 + ServerRow(flows, editingServer, onEditingServerChange)
351 + if (editingServer) return@SheetColumn
231 352 OutlinedTextField(
232 353 value = email,
233 354 onValueChange = { email = it },
added android/app/src/test/java/org/neiam/cartosnap/app/auth/login/ServerChoiceTest.kt
+73 −0
@@ -0,0 +1,73 @@
1 +package org.neiam.cartosnap.app.auth.login
2 +
3 +import org.junit.Assert.assertEquals
4 +import org.junit.Assert.assertFalse
5 +import org.junit.Assert.assertNull
6 +import org.junit.Assert.assertTrue
7 +import org.junit.Test
8 +
9 +class ServerChoiceTest {
10 + private val default = "https://cs.neiam.org"
11 +
12 + @Test
13 + fun `a fresh install uses the build's default`() {
14 + assertEquals(default, ServerChoice.initial(null, default))
15 + assertEquals(default, ServerChoice.initial(null, "cs.neiam.org/"))
16 + }
17 +
18 + @Test
19 + fun `the last server used wins over the default`() {
20 + assertEquals("https://other.example", ServerChoice.initial("https://other.example", default))
21 + }
22 +
23 + @Test
24 + fun `a saved value that is no server falls back to the default`() {
25 + assertEquals(default, ServerChoice.initial("not a server", default))
26 + assertEquals(default, ServerChoice.initial("", default))
27 + }
28 +
29 + @Test
30 + fun `an edit is normalised`() {
31 + assertEquals("https://app.example.org", ServerChoice.parse(" app.example.org/ "))
32 + assertEquals("https://app.example.org", ServerChoice.parse("HTTPS://App.Example.org"))
33 + assertEquals("http://10.0.2.2:4000", ServerChoice.parse("http://10.0.2.2:4000"))
34 + assertEquals("http://localhost:4000", ServerChoice.parse("http://localhost:4000"))
35 + }
36 +
37 + @Test
38 + fun `anything that isn't a bare server address is refused`() {
39 + listOf(
40 + "", " ", "app example org", "ftp://app.example.org", "https://",
41 + "https://app.example.org/path", "https://app.example.org/?x=1",
42 + "https://user@app.example.org", "intranet", "cartosnap://auth",
43 + ).forEach { assertNull(it, ServerChoice.parse(it)) }
44 + }
45 +
46 + @Test
47 + fun `an invalid edit keeps the server in use, with an error`() {
48 + val e = ServerChoice.edit("https://other.example", "no such thing")
49 + assertEquals("https://other.example", e.server)
50 + assertEquals(ServerChoice.INVALID, e.error)
51 + }
52 +
53 + @Test
54 + fun `a valid edit replaces it`() {
55 + val e = ServerChoice.edit(default, "other.example")
56 + assertEquals("https://other.example", e.server)
57 + assertNull(e.error)
58 + }
59 +
60 + @Test
61 + fun `reset to default is offered only off the default`() {
62 + assertTrue(ServerChoice.isDefault("https://CS.neiam.org/", default))
63 + assertFalse(ServerChoice.isDefault("https://other.example", default))
64 + // After a reset the initial choice is the default again.
65 + assertEquals(default, ServerChoice.initial(null, default))
66 + }
67 +
68 + @Test
69 + fun `the host is what the sheets show`() {
70 + assertEquals("cs.neiam.org", ServerChoice.host(default))
71 + assertEquals("10.0.2.2:4000", ServerChoice.host("http://10.0.2.2:4000"))
72 + }
73 +}
modified docs/app-login.md
+8 −2
@@ -24,9 +24,15 @@ neiam_auth (`NeiamAuth.App`, v0.5.0).
24 24 - **Username**: the email, with "Email me a sign-in link" first. Below it
25 25 are a password field and "Sign in", for accounts that have set a password
26 26 (Settings on the web).
27 +- **The server**: the last one used, else the build's default
28 + (`DEFAULT_SERVER`, cs.neiam.org), so the page loads at once. The OIDC and
29 + Username sheets show it as text with **Change**, which opens an editor
30 + already filled in with it: Use applies it, Reset to default goes back to
31 + cs.neiam.org, and an address that isn't one keeps the server in use with
32 + an error. Back closes the editor before the sheet. If the server can't be
33 + reached, OIDC and Username still open, so it can be changed.
27 34 - **Help** explains each way in, where the pairing code is, that emailed
28 − sign-in links open the app, and the server in use (which can be changed
29 − there).
35 + sign-in links open the app, and the server in use (changed in the sheets).
30 36
31 37 The code is `android/app/src/main/java/org/neiam/cartosnap/app/auth/login/`.
32 38 It is the same as in the other NEIAM apps except the package name and the

Parents: cf032d1