|
@ -6,7 +6,8 @@ from urllib.parse import urlparse, urljoin |
|
|
|
|
|
|
|
|
import flask |
|
|
import flask |
|
|
from flask import Flask, redirect, render_template, request, g, flash, url_for |
|
|
from flask import Flask, redirect, render_template, request, g, flash, url_for |
|
|
from flask_login import LoginManager, login_required, login_user, logout_user, UserMixin |
|
|
|
|
|
|
|
|
from flask_login import LoginManager, login_required, login_user, logout_user, \ |
|
|
|
|
|
UserMixin |
|
|
from flask_wtf import CSRFProtect |
|
|
from flask_wtf import CSRFProtect |
|
|
|
|
|
|
|
|
from db import get_db, get_registration_codes, add_registration_code, \ |
|
|
from db import get_db, get_registration_codes, add_registration_code, \ |
|
@ -145,14 +146,18 @@ def registration(): |
|
|
flash("Registration Configuration Is Invalid. Contact Administrator!") |
|
|
flash("Registration Configuration Is Invalid. Contact Administrator!") |
|
|
return render_template('register.html', form=form) |
|
|
return render_template('register.html', form=form) |
|
|
else: |
|
|
else: |
|
|
successful = register_new_user( |
|
|
|
|
|
|
|
|
response = register_new_user( |
|
|
form.username.data, |
|
|
form.username.data, |
|
|
form.password.data, |
|
|
form.password.data, |
|
|
app.config.get("MATRIX_HOMESERVER"), |
|
|
app.config.get("MATRIX_HOMESERVER"), |
|
|
app.config.get("MATRIX_SHARED_SECRET") |
|
|
app.config.get("MATRIX_SHARED_SECRET") |
|
|
) |
|
|
) |
|
|
if successful: |
|
|
|
|
|
add_registered_user(form.registration_code.data, form.username.data) |
|
|
|
|
|
|
|
|
if response is not None: |
|
|
|
|
|
registered_user_id = response['user_id'] |
|
|
|
|
|
add_registered_user( |
|
|
|
|
|
form.registration_code.data, |
|
|
|
|
|
form.username.data, |
|
|
|
|
|
registered_user_id) |
|
|
return redirect(get_successful_registration_redirect()) |
|
|
return redirect(get_successful_registration_redirect()) |
|
|
else: |
|
|
else: |
|
|
flash("Registration Failure. Contact Administrator!") |
|
|
flash("Registration Failure. Contact Administrator!") |
|
|