npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

laravel-auth

v1.0.9

Published

Laravel Jwt Auth Package

Readme

laravel-auth

laravel jwt 对接laravel后端的扩展

  1. 提供注册、登录(获取token),重设密码等路由和页面
  2. 提供登陆后回调,有认证数据回调,你可以在回调中使用store储存这些数据
  3. token 自动刷新

使用

  1. 执行 npm i -S laravel-auth
  2. main.js 添加
     // 认证相关的回调处理,必须放在任何需要认证的接口请求前
     import authRegister from './bootstrap/authRegister'
     Vue.use(authRegister);
    添加文件 src/bootstrap/authRegister.js
    import auth from "laravel-auth";
    import userStore from "../store/userStore";
    import httpErrorHandle from './httpErrorHandle'
       
    export default {
        install(vue){
            // 认证过程中的异常
            auth.httpErrorHandle = httpErrorHandle;
       
            // 登陆后储存用户数据
            auth.authAfter(() => {
                userStore.commit('setUser', auth.user())
            });
       
            // 注册到Vue,用来注销之类的操作
            vue.prototype.$auth = auth;
       
            // 页面初始化时调用认证类从localStorage恢复数据
            auth.restoreAuthData();
        }
    };
       

App.vuecreated 方法中添加,添加在这里是因为只有Vue示例中才能访问到$router

 // 注销后跳转到登录页面
 // 两种情况,一个是后端返回无权限,一个是点击注销按钮(调用注销api)
 auth.logoutAfter(() => {
     this.$router.push({name:'login'})
 });

router.js 中添加

import authRoutes from 'laravel-auth/routes'
const router = new Router({
    mode: 'history',
    routes: [
        ...authRoutes,
        {
            path: '/',
            name: 'home',
            component: Home
        },
    ],
});

// 如果需要防止登陆后仍然跳转到登录页面,或者未登录状态跳到需要认证的页面,可以加上下面的路由守卫
router.beforeEach(function(to, from, next) {
    if (to.name === "login" && auth.isLogin()){
        return next({name: 'home'})
    }

    if(['login', 'forgot_password', 'reset_password', 'register'].indexOf(to.name) === -1 && !auth.isLogin()){
        return next({name: 'login'})
    }
    return next()
},);
  1. 在后端项目添加 https://packagist.org/packages/shellus/laravel-auth