MCPcopy Create free account
hub / github.com/codingforentrepreneurs/full-stack-python / MyRegisterState

Class MyRegisterState

full_stack_python/auth/state.py:60–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58
59
60class MyRegisterState(reflex_local_auth.RegistrationState):
61 def handle_registration(
62 self, form_data
63 ) -> rx.event.EventSpec | list[rx.event.EventSpec]:
64 """Handle registration form on_submit.
65
66 Set error_message appropriately based on validation results.
67
68 Args:
69 form_data: A dict of form fields and values.
70 """
71 username = form_data["username"]
72 password = form_data["password"]
73 validation_errors = self._validate_fields(
74 username, password, form_data["confirm_password"]
75 )
76 if validation_errors:
77 self.new_user_id = -1
78 return validation_errors
79 self._register_user(username, password)
80 return self.new_user_id
81
82 def handle_registration_email(self, form_data):
83 new_user_id = self.handle_registration(form_data)
84 if new_user_id >= 0:
85 with rx.session() as session:
86 session.add(
87 UserInfo(
88 email=form_data["email"],
89 user_id=self.new_user_id,
90 )
91 )
92 session.commit()
93 return type(self).successful_registration

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected