|
|
@ -1285,30 +1285,33 @@ def register():
|
|
|
|
|
|
|
|
|
|
|
|
if request.method == "POST":
|
|
|
|
if request.method == "POST":
|
|
|
|
to_save = request.form.to_dict()
|
|
|
|
to_save = request.form.to_dict()
|
|
|
|
if not to_save["nickname"] or not to_save["email"]:
|
|
|
|
if config.config_register_email:
|
|
|
|
|
|
|
|
nickname = to_save["email"]
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
nickname = to_save["nickname"]
|
|
|
|
|
|
|
|
if not nickname or not to_save["email"]:
|
|
|
|
flash(_(u"Please fill out all fields!"), category="error")
|
|
|
|
flash(_(u"Please fill out all fields!"), category="error")
|
|
|
|
return render_title_template('register.html', title=_(u"register"), page="register")
|
|
|
|
return render_title_template('register.html', title=_(u"register"), page="register")
|
|
|
|
|
|
|
|
|
|
|
|
existing_user = ub.session.query(ub.User).filter(func.lower(ub.User.nickname) == to_save["nickname"]
|
|
|
|
|
|
|
|
|
|
|
|
existing_user = ub.session.query(ub.User).filter(func.lower(ub.User.nickname) == nickname
|
|
|
|
.lower()).first()
|
|
|
|
.lower()).first()
|
|
|
|
existing_email = ub.session.query(ub.User).filter(ub.User.email == to_save["email"].lower()).first()
|
|
|
|
existing_email = ub.session.query(ub.User).filter(ub.User.email == to_save["email"].lower()).first()
|
|
|
|
if not existing_user and not existing_email:
|
|
|
|
if not existing_user and not existing_email:
|
|
|
|
content = ub.User()
|
|
|
|
content = ub.User()
|
|
|
|
# content.password = generate_password_hash(to_save["password"])
|
|
|
|
|
|
|
|
if check_valid_domain(to_save["email"]):
|
|
|
|
if check_valid_domain(to_save["email"]):
|
|
|
|
content.nickname = to_save["nickname"]
|
|
|
|
content.nickname = nickname
|
|
|
|
content.email = to_save["email"]
|
|
|
|
content.email = to_save["email"]
|
|
|
|
password = generate_random_password()
|
|
|
|
password = generate_random_password()
|
|
|
|
content.password = generate_password_hash(password)
|
|
|
|
content.password = generate_password_hash(password)
|
|
|
|
content.role = config.config_default_role
|
|
|
|
content.role = config.config_default_role
|
|
|
|
content.sidebar_view = config.config_default_show
|
|
|
|
content.sidebar_view = config.config_default_show
|
|
|
|
# content.mature_content = bool(config.config_default_show & constants.MATURE_CONTENT)
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
ub.session.add(content)
|
|
|
|
ub.session.add(content)
|
|
|
|
ub.session.commit()
|
|
|
|
ub.session.commit()
|
|
|
|
if feature_support['oauth']:
|
|
|
|
if feature_support['oauth']:
|
|
|
|
register_user_with_oauth(content)
|
|
|
|
register_user_with_oauth(content)
|
|
|
|
send_registration_mail(to_save["email"], to_save["nickname"], password)
|
|
|
|
send_registration_mail(to_save["email"], nickname, password)
|
|
|
|
except Exception:
|
|
|
|
except Exception:
|
|
|
|
ub.session.rollback()
|
|
|
|
ub.session.rollback()
|
|
|
|
flash(_(u"An unknown error occurred. Please try again later."), category="error")
|
|
|
|
flash(_(u"An unknown error occurred. Please try again later."), category="error")
|
|
|
|