Interaction lost when adding/changing children in a password secured dashboard.

I want to add a password functionality to a bokeh dashboard (a modified and extended code based on the example shown here, I also posted this problem here). The logic behind is that I create a dashboard with a “passblock” item where a password can be entered and a second block which is empty. If the password is correct the “passblock” item is removed and the empty placeholder bloxk is filled with the interactive dashboard block. In this example the interactive dashboard is the slider and if you change it the value is printed via the callback function. While the callback works fine if I directly include a range slider in the dashboard section (see commented section) it is not working any more if the password and user have been entered correctly. Even if I add the range_slider before and only replace it with the new one within the verify_pwd section it is not working. So what do I need to change? Any ideas appreciated.

from bokeh.models.widgets import PasswordInput,Button, TextInput,PreText,RangeSlider
from bokeh.layouts import column, row
PASSWD = "1" #password
USER = "1" #username
max_count_tries = 5 #max allowed tries before dashboard is killed
count_tries = 0  # counter for max tries

def verify_pwd():
        """ verifies if user and pwd are entered correctly. If so the password block is set to zero and the
dashboard block which was zero before is replaced by the slider"""
    global count_tries
global range_slider
if (pwd.value==PASSWD) & (user.value == USER): #pwe and user entered correctly
        print('logged in')
        range_slider = RangeSlider(start=0., end=10., value=(2.,3.), step=.1, title="secret slider")
        layout.children[0] = row([])
        layout.children[1] = row([range_slider])
    else: #pwd or user are wrong
        if (pwd.value!=PASSWD) & (user.value == USER):
            mytext.text = ''.join(['wrong password!\n',str(max_count_tries-count_tries), ' tries left'])
        elif (pwd.value==PASSWD) & (user.value != USER):
            mytext.text = ''.join(['wrong user!\n',str(max_count_tries-count_tries), ' tries left'])
            mytext.text = ''.join(['wrong user and wrong password!\n',str(max_count_tries-count_tries), ' tries left'])
        count_tries += 1
        if count_tries>max_count_tries:
           layout.children[0] = row([])

def callback(attrname, old, new):
    # Get the current slider values and print the value in the console
    global range_slider
lower = range_slider.value[0]
    upper = range_slider.value[1]

mytext = PreText() #placeholder for error message
user = TextInput(title="UserName:") # unser name entry field
pwd = PasswordInput(title="Password:") #password entry field
btn = Button(label="login") # button to log in
btn.on_click(verify_pwd) # if button was clicked compare pwd and user with entries

passblock = row([user, pwd, btn, mytext]) # create a block to the dashboard where the pwd and user can be entered

range_slider = RangeSlider(start=0., end=10., value=(0.,0.), step=.1, title="dummy") # create a dummy slider which is not used
range_slider.on_change('value', callback) # callback for slider if values change

layout = column(passblock,row([])) # create a layout with the password block and an empty block which is filled as soon as the pwd and user are ok
#layout = column(passblock,range_slider)

# create bokeh document and deploy it
from import curdoc