diff --git a/accounts.py b/accounts.py
index a3b8228..db32573 100644
--- a/accounts.py
+++ b/accounts.py
@@ -33,8 +33,12 @@ def generate_cookie():
# Create a new user
def create_user(email, domain, password):
- if len(email) < 4 or len(domain) < 4 or len(password) < 4:
- return {'success': False, 'message': 'Invalid email, domain, or password'}
+ if len(email) < 4:
+ return {'success': False, 'message': 'Unfortunatly your email is not valid'}
+ if len(domain) < 4:
+ return {'success': False, 'message': 'We only allow domains with 4 or more characters'}
+ if len(password) < 4:
+ return {'success': False, 'message': 'Your password is not complex enough'}
# Hash password
@@ -52,13 +56,13 @@ def create_user(email, domain, password):
# Check if user exists
if db.search_users(email) != []:
- return {'success': False, 'message': 'User already exists'}
+ return {'success': False, 'message': 'It looks like someone already is using that email address'}
if db.search_users_domain(domain) != []:
- return {'success': False, 'message': 'Domain already exists'}
+ return {'success': False, 'message': 'Someone has already claimed that domain'}
db.add_user(email, domain, hashed_password, token)
- return {'success': True, 'message': 'User created', 'token': token}
+ return {'success': True, 'message': 'Congrats on creating an account', 'token': token}
def validate_token(token):
search = db.search_users_token(token)
@@ -83,11 +87,11 @@ def login(email,password):
# Verify email
search = db.search_users(email)
if search == []:
- return {'success': False, 'message': 'Invalid email'}
+ return {'success': False, 'message': 'Sorry, we couldn\'t find your account
Check your email and password'}
user = convert_db_users(search[0])
# Verify password
if not verify_password(password, user['password']):
- return {'success': False, 'message': 'Invalid password'}
+ return {'success': False, 'message': 'Sorry, we couldn\'t find your account
Check your email and password'}
# Create a cookie
token = generate_cookie()
diff --git a/main.py b/main.py
index 5813e23..03999d9 100644
--- a/main.py
+++ b/main.py
@@ -35,7 +35,7 @@ def assets(path):
def error(message):
- return jsonify({'success': False, 'message': message}), 400
+ return render_template('error.html', message=message)
@app.route('/')
def index():
@@ -67,10 +67,8 @@ def signup():
password = request.form['password']
# Verify domain
- if domain.startswith('_') or domain.endswith('_'):
- return error('Invalid domain')
if not re.match("^[a-z0-9]*$", domain):
- return error('Invalid domain')
+ return error('Sorry domain can only contain lowercase letters and numbers')
try:
valid = validate_email(email)
@@ -106,7 +104,7 @@ def edit():
token = request.cookies['token']
if not accounts.validate_token(token):
- return error('Invalid token')
+ return error('Sorry we had an issue verifying your account')
# Verify token
user = accounts.validate_token(token)
if not user:
@@ -163,7 +161,7 @@ def edit():
def send_edit():
token = request.cookies['token']
if not accounts.validate_token(token):
- return error('Invalid token')
+ return error('Sorry we had an issue verifying your account')
# Verify token
user = accounts.validate_token(token)
if not user:
@@ -199,7 +197,7 @@ def send_edit():
def logout():
token = request.cookies['token']
if not accounts.logout(token)['success']:
- return error('Invalid token')
+ return error('Sorry we had an issue verifying your account')
# Remove cookie
resp = make_response(redirect('/'))
@@ -216,7 +214,7 @@ def claim():
def hnschat():
token = request.cookies['token']
if not accounts.validate_token(token):
- return error('Invalid token')
+ return error('Sorry we had an issue verifying your account')
# Verify token
user = accounts.validate_token(token)
if not user:
@@ -231,7 +229,7 @@ def hnschat():
def save_hnschat():
token = request.cookies['token']
if not accounts.validate_token(token):
- return error('Invalid token')
+ return error('Sorry we had an issue verifying your account')
# Verify token
user = accounts.validate_token(token)
if not user:
diff --git a/templates/error.html b/templates/error.html
new file mode 100644
index 0000000..350cd7a
--- /dev/null
+++ b/templates/error.html
@@ -0,0 +1,58 @@
+
+
+
+
{{message | safe}}
+Copyright © ShakeCities 2023
+