CodeCoupler Authentication Module Status Vue
What is this?
This Vue component uses an authentication module to display an icon indicating the user's authentication status. Depending on the status, four different icons are displayed, providing different actions:
- Loading: The authentication module is initialising. No action occurs when clicked.
- Error: The authentication module did not initialise successfully. Clicking opens a dropdown menu which provides information about the cause of the error and the option to reload the page.
- Login: The authentication module has been initialised and the user is not authenticated. Clicking will start the login process.
- User: The authentication module is initialised and the user is not authenticated. Clicking will open a dropdown menu with the option to log out and display all available user information.
The component uses bootstrap in combination with @popperjs/core to display the dropdown.
Setup
Install Bundle:
Define Aliases, Externals and Assets:
Basic Usage
Use it with JavaScript:
Use it as a CodeCoupler Costa Component:
Use it as Vue component:
Icons
The following identifiers can be used in the following:
- error
- loading
- login
- logout
- user
- reload
CSS Classes:
The icons will use the class icon and the identifier as classname.
Override default icons:
You can override the default icons using the property iconsComponent. Create a Vue file with
multiple svg icons and tag them with v-if like shown below. Place them all in one span element.
Define then one prop icon:
| icons-component-custom.vue | |
|---|---|
Import this file and use this as prop:
Dropdown Menu and Items
The dropdown menu will be rendered into the body of the document. For this reason, in addition to
the dropdown-menu class, you can assign an additional class to the dropdown using the
dropdownClasses prop to target it more precisely.
Each entry in the dropdown menu has the class dropdown-item. In addition, an extra class specifies
the type of content, which contains specific inner elements.
Dropdown item with an icon and text:
You can select a specific dropdown menu item with an icon and text by adding the
identifier: & a.dropdown-item.identifier {}. Possible identifiers:
- logout
- loading
- reload
Dropdown item with error message:
Dropdown item with user information:
Reference
The following props can be passed:
auth: Object-
Authentication module instance.
dropdownClasses: String-
Additional class names for dropdown menu element. The specified classes will be set via the
setClassfunction from the@codecoupler/dom-bundlepackage. You can provide one or more class names as a string of space-separated values or as an array of strings. See above. iconsComponent: Vue-
Overrides the default icons. See above.
texts: Object-
Redefine all texts here:
showIcons: Object-
To show the icons regardless of the current status you can pass the identifier as properties and the value
trueto this object. Example:{ identifier1: true }.