views.py
def login():
    """This function allows to execute the login"""
    if request.method == "POST":
        print("Check login DB")
        username = request.form["username"]
        password = request.form["password"]
        print(username,password)
        try:
            count,userDB = managedb.loginDB(username)
            print(userDB)
            if(count == 0):
                session["logged_in"] = False
                print("login failed")
                return redirect(url_for('index'))
            else:
                pass_hash = userDB["password"]
                if (check_password_hash(pass_hash, password) or (password == pass_hash)):
                    session["logged_in"] = True
                    session["username"] = userDB["username"]
                    session["role"] = userDB["role"]
                    #print("Utente che accede nome:",session["username"])
                    #print("login corretto")
                    return redirect(url_for('main'))
                else:
                    session["logged_in"] = False
                    print("login failed")
                    return redirect(url_for('index'))
        except Exception as e:
            print("exception error DB11", str(e))
            return redirect(url_for('index'))

    return redirect(url_for('index'))
This function allows to execute the login
This function allows to execute the login
This function allows to execute the login
def login():
    if request.method == "POST":
        print("Check login DB")
        username = request.form["username"]
        password = request.form["password"]
        print(username,password)
        try:
            count,userDB = managedb.loginDB(username)
            print(userDB)
            if(count == 0):
                session["logged_in"] = False
                print("login failed")
                return redirect(url_for('index'))
            else:
                pass_hash = userDB["password"]
                if (check_password_hash(pass_hash, password) or (password == pass_hash)):
                    session["logged_in"] = True
                    session["username"] = userDB["username"]
                    session["role"] = userDB["role"]
                    return redirect(url_for('main'))
                else:
                    session["logged_in"] = False
                    print("login failed")
                    return redirect(url_for('index'))
        except Exception as e:
            print("exception error DB11", str(e))
            return redirect(url_for('index'))
    return redirect(url_for('index'))
def login ( ) : if request . method == "POST" : print ( "Check login DB" ) username = request . form [ "username" ] password = request . form [ "password" ] print ( username , password ) try : count , userDB = managedb . loginDB ( username ) print ( userDB ) if ( count == 0 ) : session [ "logged_in" ] = False print ( "login failed" ) return redirect ( url_for ( 'index' ) ) else : pass_hash = userDB [ "password" ] if ( check_password_hash ( pass_hash , password ) or ( password == pass_hash ) ) : session [ "logged_in" ] = True session [ "username" ] = userDB [ "username" ] session [ "role" ] = userDB [ "role" ] return redirect ( url_for ( 'main' ) ) else : session [ "logged_in" ] = False print ( "login failed" ) return redirect ( url_for ( 'index' ) ) except Exception as e : print ( "exception error DB11" , str ( e ) ) return redirect ( url_for ( 'index' ) ) return redirect ( url_for ( 'index' ) )
This function allows to execute the login
This function allows to execute the login
"""This function allows to execute the login""" #print("Utente che accede nome:",session["username"]) #print("login corretto")