0.0.3 • Published 2 years ago

casdoor-vue-sdk-test v0.0.3

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
2 years ago

casdoor-vue-sdk

NPM version NPM download codebeat badge GitHub Actions GitHub Actions Coverage Status Release Gitter

This is Casdoor's SDK for js will allow you to easily connect your application to the Casdoor authentication system without having to implement it from scratch.

Casdoor SDK is very simple to use. We will show you the steps below.

Noted that this sdk has been applied to casnode, if you still don’t know how to use it after reading README.md, you can refer to it

Installation

# NPM
npm i casdoor-vue-sdk

# Yarn
yarn add casdoor-vue-sdk

Init SDK

Initialization requires 5 parameters, which are all string type:

Name (in order)MustDescription
serverUrlYesyour Casdoor server URL
clientIdYesthe Client ID of your Casdoor application
appNameYesthe name of your Casdoor application
organizationNameYesthe name of the Casdoor organization connected with your Casdoor application
redirectPathNothe path of the redirect URL for your Casdoor application, will be /callback if not provided

install:

// in main.js
import Casdoor from 'casdoor-vue-sdk'
const config = {
  serverUrl: "http://localhost:7001",
  clientId: "288fdc8522f360207141",
  organizationName: "casbin-forum",
  appName: "forum",
  redirectPath: "/callback",
};
const app = createApp(App)
app.use(Casdoor, config)

example:

// in app.vue
<script>
export default {
  name: 'App',
  methods: {
    login() {
      window.location.href = this.getSigninUrl();
    },
    signup() {
      window.location.href = this.getSignupUrl();
    }
  }
}
</script>

For developer:

use command webpack in the root directory to build the sdk