<s> from flask import Blueprint , g , request , session , redirect , url_for <EOL> from . . extensions import ldap <EOL> core = Blueprint ( '<STR_LIT>' , __name__ ) <EOL> @ core . route ( '<STR_LIT:/>' ) <EOL> @ ldap . login_required <EOL> def index ( ) : <EOL> return '<STR_LIT>' <EOL> @ core . route ( '<STR_LIT>' , methods = [ '<STR_LIT:GET>' , '<STR_LIT:POST>' ] ) <EOL> def login ( ) : <EOL> if g . user : <EOL> return redirect ( url_for ( '<STR_LIT:index>' ) ) <EOL> if request . method == '<STR_LIT:POST>' : <EOL> user = request . form [ '<STR_LIT:user>' ] <EOL> passwd = request . form [ '<STR_LIT>' ] <EOL> test = ldap . bind_user ( user , passwd ) <EOL> if test is None or passwd == '<STR_LIT>' : <EOL> return '<STR_LIT>' <EOL> else : <EOL> session [ '<STR_LIT>' ] = request . form [ '<STR_LIT:user>' ] <EOL> return redirect ( '<STR_LIT:/>' ) <EOL> return """<STR_LIT>""" <EOL> @ core . route ( '<STR_LIT>' ) <EOL> @ ldap . group_required ( groups = [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> def group ( ) : <EOL> return '<STR_LIT>' <EOL> @ core . route ( '<STR_LIT>' ) <EOL> def logout ( ) : <EOL> session . pop ( '<STR_LIT>' , None ) <EOL> return redirect ( url_for ( '<STR_LIT:index>' ) ) </s>
