GithubHelp home page GithubHelp logo

Comments (5)

ItalyPaleAle avatar ItalyPaleAle commented on September 28, 2024 1

You can return false from the condition function, then listen to the “conditionFailed” event to redirect the user (use the replace() method from this router)

from svelte-spa-router.

ItalyPaleAle avatar ItalyPaleAle commented on September 28, 2024

It's very hard for me to help without seeing more context.

What I'd normally recommend is to use route pre-conditions to redirect users to your #login endpoint if needed: https://github.com/ItalyPaleAle/svelte-spa-router/blob/master/Advanced%20Usage.md#route-pre-conditions

from svelte-spa-router.

Neptunium1129 avatar Neptunium1129 commented on September 28, 2024

app.svelte is branched for three conditions: customer, developer, and external developer. However, I thought that it is not suitable for preconditions because it only applies to true or false.

from svelte-spa-router.

Neptunium1129 avatar Neptunium1129 commented on September 28, 2024

image

'/': wrap({
        asyncComponent: () => import("./components/work/main.svelte"),
        userData: {
            hello: 'world',
            foo: 'bar',
            myFunc: () => {
                console.log('login do something!');
            }
        },
        conditions: [
            // First pre-condition function
            async (detail) => {
                let result = false;
                console.log("Pre-condition 1 executed : ", detail);
                //session check
                debugger;
                await api.post("login/loginCheck", "", null).then((res)=>{
                    console.log(res);
                    if(res.data.responseMessage=="FAIL"){
                        result = false;
                    }else{
                        result = true;
                        userSession.set(res.data.data);
                    }
                })
                // Pre-condition succeeds only 50% of times
                return result;
            },
        ]
    }),

from svelte-spa-router.

Neptunium1129 avatar Neptunium1129 commented on September 28, 2024

Thansk!

from svelte-spa-router.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.