Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Commit
·
5987558
1
Parent(s):
17d63c5
wip
Browse files
app.py
CHANGED
@@ -171,27 +171,27 @@ def add_solution_cbk(
|
|
171 |
# return gr.update(value='<script>window.location.href = "/logout";</script>')
|
172 |
|
173 |
|
174 |
-
def gate_submission_by_prof(profile: gr.OAuthProfile | None):
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
|
179 |
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
|
196 |
|
197 |
def get_theme():
|
@@ -218,8 +218,6 @@ def get_theme():
|
|
218 |
blocks = gr.Blocks(css=custom_css, theme=get_theme())
|
219 |
with blocks:
|
220 |
|
221 |
-
# reload_html = gr.HTML(visible=False)
|
222 |
-
|
223 |
gr.Image(
|
224 |
"assets/banner.png",
|
225 |
interactive=False,
|
@@ -274,6 +272,12 @@ with blocks:
|
|
274 |
gr.Markdown("Please sign in to continue:")
|
275 |
gr.LoginButton()
|
276 |
|
|
|
|
|
|
|
|
|
|
|
|
|
277 |
# Shown when logged IN
|
278 |
submit_panel = gr.Group(visible=False)
|
279 |
with submit_panel:
|
@@ -324,7 +328,7 @@ with blocks:
|
|
324 |
|
325 |
# On initial load (and after OAuth redirect), toggle the UI based on login status.
|
326 |
# blocks.load(gate_submission, inputs=None, outputs=[login_box, submit_panel])
|
327 |
-
blocks.load(
|
328 |
|
329 |
|
330 |
logger.info("Scheduler")
|
|
|
171 |
# return gr.update(value='<script>window.location.href = "/logout";</script>')
|
172 |
|
173 |
|
174 |
+
# def gate_submission_by_prof(profile: gr.OAuthProfile | None):
|
175 |
+
# if not profile:
|
176 |
+
# return gr.update(visible=True), gr.update(visible=False)
|
177 |
+
# return gr.update(visible=False), gr.update(visible=True)
|
178 |
|
179 |
|
180 |
+
def gate_submission(oauth_token: gr.OAuthToken | None):
|
181 |
+
"""
|
182 |
+
@brief Toggles the visibility of the login box and submission panel based on the user's login status.
|
183 |
+
"""
|
184 |
+
logger.info("GATE TOKEN %s", oauth_token)
|
185 |
+
if oauth_token is None:
|
186 |
+
logger.info("GATE: NO TOKEN")
|
187 |
+
return gr.update(visible=True), gr.update(visible=False), gr.update(visible=False)
|
188 |
+
try:
|
189 |
+
whoami(oauth_token.token)
|
190 |
+
logger.info("GATE: TOKEN IS VALID")
|
191 |
+
return gr.update(visible=False), gr.update(visible=False), gr.update(visible=True)
|
192 |
+
except Exception:
|
193 |
+
logger.info("GATE: TOKEN HAS EXPIRED")
|
194 |
+
return gr.update(visible=False), gr.update(visible=True), gr.update(visible=False)
|
195 |
|
196 |
|
197 |
def get_theme():
|
|
|
218 |
blocks = gr.Blocks(css=custom_css, theme=get_theme())
|
219 |
with blocks:
|
220 |
|
|
|
|
|
221 |
gr.Image(
|
222 |
"assets/banner.png",
|
223 |
interactive=False,
|
|
|
272 |
gr.Markdown("Please sign in to continue:")
|
273 |
gr.LoginButton()
|
274 |
|
275 |
+
# Shown when login token is EXPIRED
|
276 |
+
logout_box = gr.Group(visible=False)
|
277 |
+
with logout_box:
|
278 |
+
gr.Markdown("Your login has EXPIRED. Please log out and log in again")
|
279 |
+
gr.Button("Manual Logout", link="/logout")
|
280 |
+
|
281 |
# Shown when logged IN
|
282 |
submit_panel = gr.Group(visible=False)
|
283 |
with submit_panel:
|
|
|
328 |
|
329 |
# On initial load (and after OAuth redirect), toggle the UI based on login status.
|
330 |
# blocks.load(gate_submission, inputs=None, outputs=[login_box, submit_panel])
|
331 |
+
blocks.load(gate_submission, inputs=None, outputs=[login_box, logout_box, submit_panel])
|
332 |
|
333 |
|
334 |
logger.info("Scheduler")
|