Redirect on successful registration callback

I’m trying to implement a simple registration page, which would redirect user to login page upon successful registration.

If not, the system prints an error message on the same page.

I’ve not been able to have the redirect and output box in the callbacks outputs because only either of each gets called depending on situation. I managed to get it to work by returning the success message on the same page, but it’s a bit clumsy and suboptimal.

How can I get the page to redirect to login page upon successfus registration?

    [Output('container-button-basic', "children"),
     #Output('url_loginxx', 'pathname') << cannot get this to work
    [Input('submit-val', 'n_clicks')],
        State('email_username', 'value'),
        State('password', 'value'),
        State('registration_code', 'value')
def insert_users(n_clicks, email_username, pw, registration_code):
    hashed_password = ''
    if pw is not None: hashed_password = generate_password_hash(pw, method='sha256')
    if email_username is not None and pw is not None and registration_code == 'XXX': #is not None:
        ins = Users_tbl.insert().values(username=email_username, password=hashed_password)
        conn = engine.connect()
        return [html.Div([html.H2('registration successful!'),login])] #return in-page login while the registration box is still there
        if email_username is not None:
            if '@' not in email_username:
                return [html.Div([html.H2('error: invalid username'),link_to_main])]
        if pw is not None:
            if len(pw) <6:
                return [html.Div([html.H2('error: password too short'), link_to_main])]
        errors = False
        if errors == False: return [html.Div([html.H2(''), link_to_main])]

I came here looking for something very similar. And this seems to be the newest post on the topic. How to redirect an user from within a callback? Has something been done about it?

My use case is the following: I have a dash_table component with a column which, when clicked, should redirect the user to another internal page. I can get the table, the click callback to work and the proper url to redirect using dash.page_registry, but I can’t find a way to redirect the user to the page I want.

I have just figured out that, for my case, I can use markdown to create links within a dash_table. That should address my issue.

I am still looking forward to hear about the proper way to redirect a user from within a callback.

Has anyone come up with a solution to page redirection within dash?