Git Product home page Git Product logo

Comments (5)

websanova avatar websanova commented on June 23, 2024

Where is that "authenticated" parameter coming from?

On Sat, Aug 20, 2016 at 2:10 PM, FerchoCarcho [email protected]
wrote:

Hello! @websanova https://github.com/websanova Thank you for the Plugin.

I know it is asking too much, but your plugin is so good, it would be very
helpfull If you could make a demo page for making it work !
I landed to your github account because Im having an Issue with my
authenticated user trying to reach the /register page or /login page when
he/she is already In. The strange situation is
the this.$root.authenticated tell me false even it is set to True look at
this image.
[image: untitled-1]
https://cloud.githubusercontent.com/assets/11180135/17832972/9d8d18ac-66df-11e6-9859-4551d406e05c.jpg


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#12, or mute the thread
https://github.com/notifications/unsubscribe-auth/ABkcyz81uVQmULF-3_oNXFLIZTRJuIh-ks5qh0MTgaJpZM4JpIVU
.

from vue-auth.

FerchoCarcho avatar FerchoCarcho commented on June 23, 2024

Hello @websanova It is comming from :
Every route which will be transitioned to auth:true is verified with

router.beforeEach(function (transition) {

    var token = localStorage.getItem('jwt-token')
    if (transition.to.auth) {

        if (!token || token === null) {
            console.log('redirecting to Login');
            transition.redirect('/login')
        }
    }
    transition.next()
});

When the user reaches login, sets its credentials, then

 ready: function () {
 var token = localStorage.getItem('jwt-token')
        if (token !== null && token !== 'undefined') {
            var that = this

            client({ path: 'try/users/me' }).then(
                function (response) {
                    that.setLogin(response.entity);
                    that.$broadcast('data-loaded')
                },
         } )
        },

a this.authenticated Variable is set at the root component to let know the user is already login saying that logged in wants to go to /register or /login this variable will be checked to redirect to other place.

methods: {

        setLogin: function (user) {
            this.user = user;
            this.authenticated = true;
            this.token = localStorage.getItem('jwt-token')
        },

from vue-auth.

FerchoCarcho avatar FerchoCarcho commented on June 23, 2024

at the register.vue child component I have the following to verify the this.$root.authenticated variable
but it is giving me False even when at the vue devtools or $data |jsonshows it is set to true.

 module.exports = {
        route: {
                activate: function (transition) {
                    console.log(this.$root.authenticated,'$root.authenticated');
                    console.log(this.$root.$data.authenticated,'$root.$data.authenticated')

as the image above states

from vue-auth.

websanova avatar websanova commented on June 23, 2024

That variable is stored in the user object. You can just use
$auth.check() in your code. Bad idea to use variables directly, could
easily change in future versions.

On Aug 20, 2016 14:42, "FerchoCarcho" [email protected] wrote:

at the register.vue child component I have the following to verify the
this.$root.authenticated variable
but it is giving me False even when at the vue devtools or $data |jsonshows
it is set to true.

module.exports = {
route: {
activate: function (transition) {
console.log(this.$root.authenticated,'$root.authenticated');
console.log(this.$root.$data.authenticated,'$root.$data.authenticated')


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#12 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABkcy1bOd6EB0xWSDgRCVKeYJweqHrRFks5qh0qYgaJpZM4JpIVU
.

from vue-auth.

FerchoCarcho avatar FerchoCarcho commented on June 23, 2024

I'm willing to refactor my code with your plugin, because as I saw yours is the logic I would like to have on my website.
Because of that I was asking for a Demo. It would be very useful to other users too.

from vue-auth.

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.