Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including vue-aspnet-auth with all npm packages installed. Try it out:

var vueAspnetAuth = require("vue-aspnet-auth")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

vue-aspnet-auth v1.5.4

Vue plugin for auth to OWIN MVC

vue-aspnet-auth

GitHub license Build Status codecov npm Greenkeeper badge semantic-release

A Vue plugin wrapper for aspnet-auth.

Getting Started

Install

From npm

npm install vue-aspnet-auth --save

Usage

Import and initialize the plugin.

import { AspnetAuth } from 'vue-aspnet-auth';

Vue.use(AspnetAuth, {
  url: 'http://localhost:46993',
});

Basic login example:

export default {
  name: 'login',
  data() {
    return {
      username: '',
      password: '',
    };
  },
  methods: {
    login() {
      this.$auth.login(this.username, this.password, (data) => {
        if (data.result) {
          this.$store.commit('auth', this.$auth.authentication);
          this.$root.$emit('app.loggedin');
        } else {
          this.error = data.message;
        }
      });
    },
  },
  created() {
    // initialize url
    this.$auth.url = `http://localhost:1234`;
  },
};

License

Copyright © 2018 Code HQ (Pty) Ltd. This source code is licensed under the MIT license found in the LICENSE file.


Made with ♥ by Craig Pretorius

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free