|
41 | 41 | from pydantic import ValidationError |
42 | 42 | from tornado import web |
43 | 43 |
|
44 | | -from core.authenticators import CustomFirstUseAuthenticator |
| 44 | +from core.authenticators import GITHUB_USERNAME_PREFIX, CustomFirstUseAuthenticator |
45 | 45 | from core.git_validation import validate_and_sanitize_repo_url |
46 | 46 | from core.notifications import get_normalized_notifications |
47 | 47 | from core.quota import ( |
@@ -265,7 +265,7 @@ def _render_error(msg: str): |
265 | 265 | return self.finish(html) |
266 | 266 |
|
267 | 267 | username = user.name |
268 | | - if username.startswith("github:"): |
| 268 | + if username.startswith(GITHUB_USERNAME_PREFIX): |
269 | 269 | html = await _render_error("GitHub users cannot change password here") |
270 | 270 | self.set_status(400) |
271 | 271 | return self.finish(html) |
@@ -322,7 +322,7 @@ async def get(self): |
322 | 322 | from jupyterhub.orm import User |
323 | 323 |
|
324 | 324 | for user in self.db.query(User).all(): |
325 | | - if not user.name.startswith("github:") and user.name != "admin": |
| 325 | + if not user.name.startswith(GITHUB_USERNAME_PREFIX) and user.name != "admin": |
326 | 326 | native_users.append(user.name) |
327 | 327 |
|
328 | 328 | html = await self.render_template( |
@@ -356,7 +356,7 @@ async def post(self): |
356 | 356 | ) |
357 | 357 |
|
358 | 358 | username = target_user |
359 | | - if username.startswith("github:"): |
| 359 | + if username.startswith(GITHUB_USERNAME_PREFIX): |
360 | 360 | return self.redirect( |
361 | 361 | self.hub.base_url |
362 | 362 | + f"admin/reset-password?user={target_user}&error=Cannot+reset+password+for+GitHub+users" |
@@ -438,7 +438,7 @@ async def post(self): |
438 | 438 | self.set_header("Content-Type", "application/json") |
439 | 439 | return self.finish(json.dumps({"error": "Username and password are required"})) |
440 | 440 |
|
441 | | - if username.startswith("github:"): |
| 441 | + if username.startswith(GITHUB_USERNAME_PREFIX): |
442 | 442 | self.set_status(400) |
443 | 443 | self.set_header("Content-Type", "application/json") |
444 | 444 | return self.finish(json.dumps({"error": "Cannot set password for GitHub users"})) |
@@ -532,7 +532,7 @@ async def post(self): |
532 | 532 | self.set_status(400) |
533 | 533 | self.set_header("Content-Type", "application/json") |
534 | 534 | return self.finish(json.dumps({"error": "Each entry must have username and password"})) |
535 | | - if entry.get("username", "").startswith("github:"): |
| 535 | + if entry.get("username", "").startswith(GITHUB_USERNAME_PREFIX): |
536 | 536 | self.set_status(400) |
537 | 537 | self.set_header("Content-Type", "application/json") |
538 | 538 | return self.finish( |
@@ -1593,7 +1593,7 @@ async def post(self): |
1593 | 1593 | skipped = 0 |
1594 | 1594 |
|
1595 | 1595 | for user in self.users.values(): |
1596 | | - if not user.name.startswith("github:"): |
| 1596 | + if not user.name.startswith(GITHUB_USERNAME_PREFIX): |
1597 | 1597 | skipped += 1 |
1598 | 1598 | continue |
1599 | 1599 |
|
|
0 commit comments