8.1.8 • Published 3 years ago

@ubuilder/auth-vue2 v8.1.8

Weekly downloads
-
License
CC-BY-NC-ND-4.0
Repository
-
Last release
3 years ago

UBuilder Auth (vue2)

For vue 3, uses @ubuilder/auth. UBuilder 8 not compatible with version 7.

  • User authentication and autorization.

Authorized request should use Auth.rest() or this.$rest.

Installation

npm i @ubuilder/auth

Usage

import Vue from 'vue';
import Auth from '@ubuilder/auth-vue2';

const options = {/* plugin options */};
Vue.use(Auth, options);

Options

  • baseURL: string - Base URL for UBuilder auth server. Default value is '/api/auth'.
  • apiURL: string - Base URL for API server. Default value is '/'.
  • storageKey: string - LocalStorage key for current user. Default value is 'ubuilder:user'.

Provides

  • $auth: Auth - Auth API
  • $user: User - computed value of current user.
  • $rest: Rest - Rest API supports authorization.

Auth API

  • login(username: string, password: string, remember?: boolean): Promise<User> - login process
  • logout(): Promise<void> - logout process
  • currentUser(): User - get current reactive user. If not logged in, returns anonymous user - check by isLoggedIn property.
  • rest(): Rest - get @ubuilder/rest API for authorized API request.

User interface

  • token: string - Access token for UBuilder server.
  • expireAt: number - expire time
  • authorities: string[] - array of authority.
  • details: Record<string, unknown> - UserDetails from UBuidler auth server.
  • isLoggedIn: boolean - determine user is logged in.
  • hasAuthority(authority?: string): boolean - determine user has authority. When needs track user changes, should use computed.
8.1.8

3 years ago

8.1.7

3 years ago

8.1.6

3 years ago

8.1.5

3 years ago

8.1.4

3 years ago

8.1.3

3 years ago

8.1.0

3 years ago

8.1.2

3 years ago

8.1.1

3 years ago

8.0.20

3 years ago

8.0.19

3 years ago

8.0.18

3 years ago