Skip to content

Commit

Permalink
license ID must be 12 numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
abdulrahman7038 committed Nov 10, 2024
1 parent 9accec8 commit c80ca57
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 9 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ def login():
return render_template('login.html', error='Invalid email or password!')
return render_template('login.html')


def is_valid_numeric_string(s):
return s.isdigit() and len(s) == 12

@app.route('/register', methods=['GET', 'POST'])
def register():
if request.method == 'POST':
Expand All @@ -89,7 +93,11 @@ def register():
new_person.insert_doc()

else:
new_person = user(first, last, email, pwd, location, conc, "yes", bar_num, school, firm)
valid_num = is_valid_numeric_string(bar_num)
if valid_num:
new_person = user(first, last, email, pwd, location, conc, "yes", bar_num, school, firm)
else:
return render_template('register.html', error="License ID is invalid.")
new_person.insert_doc()
# Simulate user registration
session['email'] = email # Log the user in after registration
Expand Down
4 changes: 3 additions & 1 deletion index/register.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ <h1>Welcome to the Registration Portal</h1>
<label for="law_firm">Law Firm <span class="required">*</span></label><br>
<input class="input input-msg" type="text" id="law_firm" name="law_firm" placeholder="Calgary Lawyers">
</div>

{% if error %}
<p style="color: red;">{{ error }}</p>
{% endif %}
<p class="required-text"><span class="required">*</span> indicates a
required field</p>
<input class="submit-button" type="submit" value="Register">
Expand Down

0 comments on commit c80ca57

Please sign in to comment.