mirror of
https://github.com/kennethreitz/replit-py.git
synced 2026-06-05 15:00:20 +00:00
Rename kwarg in needs_signin, fix import order
This commit is contained in:
@@ -7,7 +7,7 @@ from werkzeug.local import LocalProxy
|
||||
from . import html
|
||||
from .app import App
|
||||
from .html import HTMLElement, Link, Page, Paragraph
|
||||
from .utils import sign_in_snippet, signin, needs_signin
|
||||
from .utils import needs_signin, sign_in_snippet, signin
|
||||
from ..database import db
|
||||
|
||||
auth = LocalProxy(lambda: flask.request.auth)
|
||||
|
||||
@@ -25,12 +25,14 @@ def signin(title: str = "Please Sign In") -> Page:
|
||||
return Page(title=title, body=sign_in_snippet)
|
||||
|
||||
|
||||
def needs_signin(func: Callable = None, loginhtml: str = sign_in_snippet) -> Callable:
|
||||
def needs_signin(func: Callable = None, login_html: str = sign_in_snippet) -> Callable:
|
||||
"""A decorator that enforces that the user is signed in before accessing the page.
|
||||
|
||||
Args:
|
||||
func (Callable): The function passed in if used as a decorator. Defaults to None.
|
||||
loginhtml (str): The HTML to show when the user needs to sign in. Defaults to sign_in_snippet.
|
||||
func (Callable): The function passed in if used as a decorator. Defaults to
|
||||
None.
|
||||
loginhtml (str): The HTML to show when the user needs to sign in. Defaults to
|
||||
sign_in_snippet.
|
||||
|
||||
Returns:
|
||||
Callable: The new handler.
|
||||
@@ -42,7 +44,7 @@ def needs_signin(func: Callable = None, loginhtml: str = sign_in_snippet) -> Cal
|
||||
if flask.request.signed_in:
|
||||
return func(*args, **kwargs)
|
||||
else:
|
||||
return loginhtml
|
||||
return login_html
|
||||
|
||||
if func is not None: # called with no options @needs_signin
|
||||
return decorator(func)
|
||||
|
||||
Reference in New Issue
Block a user