Skip to content

Commit 8dc9d04

Browse files
38 - Users with Reflex Local Auth
1 parent 99d2770 commit 8dc9d04

File tree

4 files changed

+44
-8
lines changed

4 files changed

+44
-8
lines changed

full_stack_python/full_stack_python.py

+14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Welcome to Reflex! This file outlines the steps to create a basic app."""
22

33
import reflex as rx
4+
import reflex_local_auth
45

56
from rxconfig import config
67
from .ui.base import base_page
@@ -46,6 +47,19 @@ def index() -> rx.Component:
4647

4748
app = rx.App()
4849
app.add_page(index)
50+
# reflex_local_auth pages
51+
app.add_page(
52+
reflex_local_auth.pages.login_page,
53+
route=reflex_local_auth.routes.LOGIN_ROUTE,
54+
title="Login",
55+
)
56+
app.add_page(
57+
reflex_local_auth.pages.register_page,
58+
route=reflex_local_auth.routes.REGISTER_ROUTE,
59+
title="Register",
60+
)
61+
62+
# my pages
4963
app.add_page(pages.about_page,
5064
route=navigation.routes.ABOUT_US_ROUTE)
5165

full_stack_python/navigation/state.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
import reflex as rx
2-
2+
import reflex_local_auth
33
from . import routes
44

55
class NavState(rx.State):
66
def to_home(self):
77
return rx.redirect(routes.HOME_ROUTE)
8+
9+
def to_register(self):
10+
return rx.redirect(reflex_local_auth.routes.REGISTER_ROUTE)
11+
12+
def to_login(self):
13+
return rx.redirect(reflex_local_auth.routes.LOGIN_ROUTE)
14+
815
def to_about_us(self):
916
return rx.redirect(routes.ABOUT_US_ROUTE)
1017
def to_blog(self):

full_stack_python/ui/nav.py

+21-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import reflex as rx
2+
import reflex_local_auth
3+
24

35
from .. import navigation
46

@@ -39,12 +41,22 @@ def navbar() -> rx.Component:
3941
spacing="5",
4042
),
4143
rx.hstack(
42-
rx.button(
43-
"Sign Up",
44-
size="3",
45-
variant="outline",
44+
rx.link(
45+
rx.button(
46+
"Register",
47+
size="3",
48+
variant="outline",
49+
),
50+
href=reflex_local_auth.routes.REGISTER_ROUTE
51+
),
52+
rx.link(
53+
rx.button(
54+
"Login",
55+
size="3",
56+
variant="outline",
57+
),
58+
href=reflex_local_auth.routes.LOGIN_ROUTE
4659
),
47-
rx.button("Log In", size="3"),
4860
spacing="4",
4961
justify="end",
5062
),
@@ -83,8 +95,10 @@ def navbar() -> rx.Component:
8395
rx.menu.item("Contact",
8496
on_click=navigation.NavState.to_contact),
8597
rx.menu.separator(),
86-
rx.menu.item("Log in"),
87-
rx.menu.item("Sign up"),
98+
rx.menu.item("Log in",
99+
on_click=navigation.NavState.to_login),
100+
rx.menu.item("Register",
101+
on_click=navigation.NavState.to_register),
88102
),
89103
justify="end",
90104
),

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
reflex==0.5.3
2+
reflex-local-auth

0 commit comments

Comments
 (0)