微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何基于安装的Vue中的角色来阻止触发请求-Laravel Vue API令牌认证用户

如何解决如何基于安装的Vue中的角色来阻止触发请求-Laravel Vue API令牌认证用户

我有一个方法,当在我的已装载的Vue页面中加载时,会调用并返回经过身份验证的用户

mounted() {
        User.auth()
            .then(response => {
                this.user = response.data;
                this.role = response.data.roles[0];

                console.log(response.data);
            })
            .catch(error => (this.user = ""));
    },

还有另一种方法,此后我要根据用户角色进行控制

User.allUser().then(response => {
             this.users = response.data;
             console.log(response.data);
         });

在触发第二种方法之前,我如何获得角色名称并进行比较?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。