Fixed signups and oauth buttons now only show if enabled

The signup form now works and the oauth buttons are only visible if they have been enabled in the settings.json file
This commit is contained in:
2025-08-26 12:16:22 +01:00
parent 349a4192e0
commit 716a4c6148
4 changed files with 17 additions and 11 deletions

View File

@@ -23,7 +23,7 @@ github_token_endpoint = "https://github.com/login/oauth/access_token"
github_user_endpoint = "https://api.github.com/user"
mongoUser = 'root'
mongoPassword = '39zj6bNT5gaXbmuOBAYn5pZRO'
mongoPassword = settings["mongo_password"]
mongoHost = 'localhost'
mongoPort = '27017'
mongoDatabase = 'database'
@@ -156,7 +156,7 @@ def createChat():
def signup():
token = request.cookies.get('auth_token', 'none')
if (token == 'none'):
return render_template('signup.html', appName=appName, githubUrl=github_auth_endpoint)
return render_template('signup.html', appName=appName, githubUrl=github_auth_endpoint, githublogin=settings["github_oauth"]["enabled"], oauthlogin=settings["oauth_login"])
# Index page
# If logged in return home menu (Or logout if token is expired),
@@ -165,7 +165,7 @@ def signup():
def index():
token = request.cookies.get('auth_token', 'none')
if (token == 'none'):
return render_template('login.html', appName=appName, githubUrl=github_auth_endpoint)
return render_template('login.html', appName=appName, githubUrl=github_auth_endpoint, githublogin=settings["github_oauth"]["enabled"], oauthlogin=settings["oauth_login"])
else:
user = usersCollection.find_one({'tokens.token': token}, {"_id":1,"tokens":{"$elemMatch": {"token":token}}})
if (user):
@@ -312,13 +312,11 @@ def handleSignup():
creationDate = int(datetime.now().timestamp())
accessCode = request.json['access_code']
displayName = request.json['displayname']
# Check if details are taken
sameUsername = usersCollection.count_documents({"username":username})
sameEmail = usersCollection.count_documents({"email":email})
if (sameUsername != 0 ) or ( sameEmail != 0):
return jsonify("User already exists")
# Check for appropriate role
codeFound = False
if (settings["signup_mode"] == "none"):