Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @app.route('/')
- @app.route('/login',methods=['GET', 'POST'])
- def login():
- error=None
- if request.method =='POST':
- s = Server('appauth.corp.domain.com:636', use_ssl=True, get_info=ALL)
- c = Connection(s,user=request.form['username'],password=request.form['password'],check_names=True, lazy=False,raise_exceptions=False)
- c.open()
- c.bind()
- if request.form['username'].lower() not in users or (c.bind() != True) is True:
- error='Invalid credentials. Please try again'
- else:
- session['username'] = request.form['username'].lower()
- return redirect(url_for('index'))
- return render_template('login.html',error=error)
- @app.route('/index',methods=['GET','POST'])
- def index():
- if 'username' in session:
- return render_template('index.html')
- @app.route('/logout')
- def logout():
- # remove the username from the session if it's there
- session.pop('username', None)
- return redirect(url_for('login'))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement