Skip to content

Commit 62ada10

Browse files
39 - Customize Login and Register Pages
1 parent 8dc9d04 commit 62ada10

File tree

3 files changed

+42
-3
lines changed

3 files changed

+42
-3
lines changed

full_stack_python/auth/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from . import pages
2+
3+
__all__ = [
4+
'pages'
5+
]

full_stack_python/auth/pages.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import reflex as rx
2+
3+
from reflex_local_auth.pages.login import LoginState, login_form
4+
from reflex_local_auth.pages.registration import RegistrationState, register_form
5+
6+
from ..ui.base import base_page
7+
8+
def my_login_page()->rx.Component:
9+
return base_page(
10+
rx.center(
11+
rx.cond(
12+
LoginState.is_hydrated, # type: ignore
13+
rx.card(login_form()),
14+
),
15+
min_height="85vh",
16+
),
17+
18+
)
19+
20+
def my_register_page()->rx.Component:
21+
return base_page(
22+
rx.center(
23+
rx.cond(
24+
RegistrationState.success,
25+
rx.vstack(
26+
rx.text("Registration successful!"),
27+
),
28+
rx.card(register_form()),
29+
30+
),
31+
min_height="85vh",
32+
)
33+
34+
)

full_stack_python/full_stack_python.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from rxconfig import config
77
from .ui.base import base_page
88

9-
from . import blog, contact, navigation, pages
9+
from . import auth, blog, contact, navigation, pages
1010

1111
class State(rx.State):
1212
"""The app state."""
@@ -49,12 +49,12 @@ def index() -> rx.Component:
4949
app.add_page(index)
5050
# reflex_local_auth pages
5151
app.add_page(
52-
reflex_local_auth.pages.login_page,
52+
auth.pages.my_login_page,
5353
route=reflex_local_auth.routes.LOGIN_ROUTE,
5454
title="Login",
5555
)
5656
app.add_page(
57-
reflex_local_auth.pages.register_page,
57+
auth.pages.my_register_page,
5858
route=reflex_local_auth.routes.REGISTER_ROUTE,
5959
title="Register",
6060
)

0 commit comments

Comments
 (0)