#NEWLINE# @ auth . route ( '/login' , methods = [ 'GET' , 'POST' ] ) #NEWLINE# def login( ) : #NEWLINE# #INDENT# 'User login' #NEWLINE# error = None #NEWLINE# if ( request . method == 'POST' ) : #NEWLINE# #INDENT# u = UsersTable . query . filter ( ( UsersTable . username == request . form [ 'username' ] ) ) . filter ( ( UsersTable . password == request . form [ 'password' ] ) ) . filter ( ( UsersTable . is_private == False ) ) . first ( ) #NEWLINE# if u : #NEWLINE# #INDENT# session [ 'logged_in_user' ] = u . id #NEWLINE# session [ 'user_name' ] = u . name #NEWLINE# flash ( 'You were logged in' ) #NEWLINE# return redirect ( url_for ( 'dashboard.index' ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# error = 'Invalid username and/or password' #NEWLINE# #UNINDENT# #UNINDENT# return render_template ( 'login.html' , error = error )