fix typos and improve messages showing at the end users

This commit is contained in:
Tung Nguyen 2019-12-26 13:00:17 +00:00
parent 47e77ed4ab
commit 4f751e5cd2
8 changed files with 20 additions and 19 deletions

View File

@ -22,15 +22,16 @@ def new_custom_alias():
optional "hostname" in args optional "hostname" in args
Output: Output:
201 if success 201 if success
409 if alias already exists 409 if the alias already exists
""" """
user = g.user user = g.user
if not user.can_create_new_alias(): if not user.can_create_new_alias():
LOG.d("user %s cannot create custom alias", user) LOG.d("user %s cannot create any custom alias", user)
return ( return (
jsonify( jsonify(
error="You have created 3 custom aliases, please upgrade to create more" error="You have reached the limitation of a free account with the maximum of "
"3 custom aliases, please upgrade your plan to create more custom aliases"
), ),
400, 400,
) )
@ -46,7 +47,7 @@ def new_custom_alias():
alias_prefix = alias_prefix.strip() alias_prefix = alias_prefix.strip()
alias_prefix = convert_to_id(alias_prefix) alias_prefix = convert_to_id(alias_prefix)
if not alias_prefix: # should be checked on frontend if not alias_prefix: # should be checked on frontend
LOG.d("user %s submits empty alias prefix %s", user, alias_prefix) LOG.d("user %s submits an empty alias with the prefix %s", user, alias_prefix)
return jsonify(error="alias prefix cannot be empty"), 400 return jsonify(error="alias prefix cannot be empty"), 400
# make sure alias_suffix is either .random_letters@simplelogin.co or @my-domain.com # make sure alias_suffix is either .random_letters@simplelogin.co or @my-domain.com
@ -54,19 +55,19 @@ def new_custom_alias():
if alias_suffix.startswith("@"): if alias_suffix.startswith("@"):
custom_domain = alias_suffix[1:] custom_domain = alias_suffix[1:]
if custom_domain not in user_custom_domains: if custom_domain not in user_custom_domains:
LOG.d("user %s submits wrong custom domain %s ", user, custom_domain) LOG.d("user %s submits a wrong custom domain %s ", user, custom_domain)
return jsonify(error="error"), 400 return jsonify(error="error"), 400
else: else:
if not alias_suffix.startswith("."): if not alias_suffix.startswith("."):
LOG.d("user %s submits wrong alias suffix %s", user, alias_suffix) LOG.d("user %s submits a wrong alias suffix %s", user, alias_suffix)
return jsonify(error="error"), 400 return jsonify(error="error"), 400
if not alias_suffix.endswith(EMAIL_DOMAIN): if not alias_suffix.endswith(EMAIL_DOMAIN):
LOG.d("user %s submits wrong alias suffix %s", user, alias_suffix) LOG.d("user %s submits a wrong alias suffix %s", user, alias_suffix)
return jsonify(error="error"), 400 return jsonify(error="error"), 400
random_letters = alias_suffix[1 : alias_suffix.find("@")] random_letters = alias_suffix[1 : alias_suffix.find("@")]
if len(random_letters) < 5: if len(random_letters) < 5:
LOG.d("user %s submits wrong alias suffix %s", user, alias_suffix) LOG.d("user %s submits a wrong alias suffix %s", user, alias_suffix)
return jsonify(error="error"), 400 return jsonify(error="error"), 400
full_alias = alias_prefix + alias_suffix full_alias = alias_prefix + alias_suffix

View File

@ -22,7 +22,7 @@ def activate():
if not activation_code: if not activation_code:
return ( return (
render_template("auth/activate.html", error="Activation code not found"), render_template("auth/activate.html", error="Activation code cannot be found"),
400, 400,
) )
@ -30,7 +30,7 @@ def activate():
return ( return (
render_template( render_template(
"auth/activate.html", "auth/activate.html",
error="Activation code is expired", error="Activation code was expired",
show_resend_activation=True, show_resend_activation=True,
), ),
400, 400,

View File

@ -48,7 +48,7 @@ def facebook_login():
def facebook_callback(): def facebook_callback():
# user clicks on cancel # user clicks on cancel
if "error" in request.args: if "error" in request.args:
flash("please use another sign in method then", "warning") flash("Please use another sign in method then", "warning")
return redirect("/") return redirect("/")
facebook = OAuth2Session( facebook = OAuth2Session(

View File

@ -40,7 +40,7 @@ def github_login():
def github_callback(): def github_callback():
# user clicks on cancel # user clicks on cancel
if "error" in request.args: if "error" in request.args:
flash("please use another sign in method then", "warning") flash("Please use another sign in method then", "warning")
return redirect("/") return redirect("/")
github = OAuth2Session( github = OAuth2Session(

View File

@ -27,7 +27,7 @@ def login():
user = User.filter_by(email=form.email.data).first() user = User.filter_by(email=form.email.data).first()
if not user: if not user:
flash("Email not exist in our system", "error") flash("The email entered does not exist in our system", "error")
elif not user.check_password(form.password.data): elif not user.check_password(form.password.data):
flash("Wrong password", "error") flash("Wrong password", "error")
elif not user.activated: elif not user.activated:

View File

@ -20,17 +20,17 @@ def resend_activation():
user = User.filter_by(email=form.email.data).first() user = User.filter_by(email=form.email.data).first()
if not user: if not user:
flash("There's no such email", "warning") flash("There is no such email", "warning")
return render_template("auth/resend_activation.html", form=form) return render_template("auth/resend_activation.html", form=form)
if user.activated: if user.activated:
flash("your account is already activated, please login", "success") flash("Your account was already activated, please login", "success")
return redirect(url_for("auth.login")) return redirect(url_for("auth.login"))
# user is not activated # user is not activated
LOG.d("user %s is not activated", user) LOG.d("user %s is not activated", user)
flash( flash(
"An activation email is on its way, please check your inbox/spam folder", "An activation email has been sent to you. Please check your inbox/spam folder.",
"warning", "warning",
) )
send_activation_email(user, request.args.get("next")) send_activation_email(user, request.args.get("next"))

View File

@ -28,13 +28,13 @@ def reset_password():
if not reset_password_code: if not reset_password_code:
error = ( error = (
"The reset password link can be used only once. " "The reset password link can be used only once. "
"Please make a new request to reset password" "Please request a new link to reset password."
) )
return render_template("auth/reset_password.html", form=form, error=error) return render_template("auth/reset_password.html", form=form, error=error)
if reset_password_code.is_expired(): if reset_password_code.is_expired():
error = ( error = (
"The link is already expired. Please make a new request to reset password" "The link has been already expired. Please make a new request of the reset password link"
) )
return render_template("auth/reset_password.html", form=form, error=error) return render_template("auth/reset_password.html", form=form, error=error)

View File

@ -86,7 +86,7 @@ def send_change_email(new_email, current_email, name, link):
def send_new_app_email(email, name): def send_new_app_email(email, name):
send_email( send_email(
email, email,
f"{name}, any questions/feedbacks for SimpleLogin?", f"{name}, any question/feedback for SimpleLogin?",
_render("new-app.txt", name=name), _render("new-app.txt", name=name),
_render("new-app.html", name=name), _render("new-app.html", name=name),
) )