Skip to content

Commit b81181d

Browse files
Fix login issue (#297)
* Fix parameter validation in login. * Fix parameter validation in login. * 💅 * 💅 * Add name to handlers and refactor.
1 parent 50bd43c commit b81181d

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

src/handlers/api.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,16 @@ class BaseHandler(BioThingsAuthnMixin, BaseAPIHandler):
4848

4949
class AuthHandler(BaseHandler):
5050
def set_cache_header(self, cache_value):
51-
# disabel cache for auth-related handlers
51+
# disable cache for auth-related handlers
5252
self.set_header("Cache-Control", "private, max-age=0, no-cache")
5353

5454

5555
class UserInfoHandler(AuthHandler):
56-
""" "Handler for /user_info endpoint."""
56+
""" "Handler for /user endpoint."""
57+
name = "user_info"
58+
kwargs = {
59+
"GET": {} # Explicitly empty - no parameters expected or required
60+
}
5761

5862
def get(self):
5963
# Check for user cookie
@@ -73,11 +77,27 @@ def get(self):
7377

7478

7579
class LoginHandler(AuthHandler):
80+
""" "Handler for /login endpoint."""
81+
name = "user_login"
82+
kwargs = {
83+
"GET": {
84+
"next": {"type": str, "required": False, "default": "/"} # Redirect URL
85+
}
86+
}
87+
7688
def get(self):
7789
self.redirect(self.get_argument("next", "/"))
7890

7991

8092
class LogoutHandler(AuthHandler):
93+
""" "Handler for /logout endpoint."""
94+
name = "user_logout"
95+
kwargs = {
96+
"GET": {
97+
"next": {"type": str, "required": False, "default": "/"} # Redirect URL
98+
}
99+
}
100+
81101
def get(self):
82102
self.clear_cookie("user")
83103
self.redirect(self.get_argument("next", "/"))

src/handlers/oauth.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77

88

99
class GitHubLoginHandler(BaseAPIHandler, GithubOAuth2Mixin):
10-
""" "Handler for GitHub oauth login"""
10+
""" "Handler for GitHub oauth login: /oauth endpoint"""
11+
name = "github_oauth"
1112

1213
SCOPES = []
1314
GITHUB_CALLBACK_PATH = "/oauth"

0 commit comments

Comments
 (0)