diff --git a/AppCode/LoginAuth.py b/AppCode/LoginAuth.py index d8c54e6..9b843eb 100644 --- a/AppCode/LoginAuth.py +++ b/AppCode/LoginAuth.py @@ -1,5 +1,8 @@ from flask import Blueprint, render_template, request, redirect, url_for, flash, session +<<<<<<< HEAD import os +======= +>>>>>>> b9a8b9c0a9c322c129ac50b3dec0ffb3c6d82a83 from functools import wraps from ldap3 import Server, Connection, ALL from ldap3.core.exceptions import LDAPException @@ -13,10 +16,14 @@ class LoginAuth: # ------------------------------- # LDAP CONFIGURATION # ------------------------------- +<<<<<<< HEAD self.LDAP_SERVER = os.getenv( "LDAP_SERVER", "ldap://host.docker.internal:389" ) +======= + self.LDAP_SERVER = "ldap://localhost:389" +>>>>>>> b9a8b9c0a9c322c129ac50b3dec0ffb3c6d82a83 self.BASE_DN = "ou=users,dc=lcepl,dc=org" # LDAP Users DN @@ -28,16 +35,30 @@ class LoginAuth: if request.method == 'POST': username = request.form.get("username") password = request.form.get("password") +<<<<<<< HEAD if not username or not password: flash("Username and password are required!", "danger") return render_template("login.html") user_dn = f"uid={username},{self.BASE_DN}" server = Server(self.LDAP_SERVER, get_info=ALL) +======= + + if not username or not password: + flash("Username and password are required!", "danger") + return render_template("login.html") + + user_dn = f"uid={username},{self.BASE_DN}" + server = Server(self.LDAP_SERVER, get_info=ALL) + +>>>>>>> b9a8b9c0a9c322c129ac50b3dec0ffb3c6d82a83 try: # Attempt LDAP bind conn = Connection(server, user=user_dn, password=password, auto_bind=True) if conn.bound: +<<<<<<< HEAD +======= +>>>>>>> b9a8b9c0a9c322c129ac50b3dec0ffb3c6d82a83 session['user'] = username flash(f"Login successful! Welcome {username}", "success") return redirect(url_for('welcome')) @@ -48,6 +69,7 @@ class LoginAuth: finally: if 'conn' in locals(): conn.unbind() +<<<<<<< HEAD # GET request: show login form return render_template("login.html") @@ -68,6 +90,12 @@ class LoginAuth: # return render_template("login.html") +======= + + # GET request: show login form + return render_template("login.html") + +>>>>>>> b9a8b9c0a9c322c129ac50b3dec0ffb3c6d82a83 # ------------------------------- # LOGOUT ROUTE # -------------------------------