authentication ⇒ WeavyWidget.plugins.authentication

Plugin for signing in and out

Kind: global mixin

Instance members

widget.nodes ⇐ nodes

The nodes placeholder in WeavyWidget

Kind: instance property of authentication
Extends: nodes

widget.nodes.authenticationPanel : Element

Panel displaying the authentication page

Kind: instance property of nodes
Created: Widget event: build

widget.nodes.authenticationFrame : FrameElement

Frame for the authenticationPanel

Kind: instance property of nodes
Created: Widget event: build

widget.signIn([username], [password]) ⇒ Promise

Open the sign-in page. An authentication attempt is started if credentials are provided.

Kind: instance method of authentication
Emits: signed-in , authentication-error
Resolves: true - On successful sign-in
Resolves: false - On authentication error
ParamType
[username]string
[password]string
Example
// Open the sign in panel and wait for the user to complete authentication
widget.signIn().then(function(signedIn) {
    if (signedIn) {
        widget.log("User has signed in");
    } else {
        widget.warn("User sign-in failed");
    }
});

widget.signOut() ⇒ Promise

Sign out from Weavy regardless of authentication provider

Kind: instance method of authentication
Emits: signed-out
Resolves: When sign-out is completed
Example
// Sign out the active user
widget.signOut().then(function() {
    // Open the sign in page
    widget.signIn();
});

Properties

widget.userState : string

Current authentication state of the user

  • "signing-in" - The user is trying to sign in. See Widget event: signing-in
  • "signed-in" - The user is signed in. See Widget event: signed-in
  • "signing-out" - The user has started the sign-out process. See Widget event: signing-out
  • "signed-out" - The user is not authenticated. See Widget event: signed-out and authentication-error
Kind: instance property of authentication
Default: "signed-out"
Category: properties

widget.signInUrl : url

The url to the sign in page

Kind: instance property of authentication
Category: properties

widget.signOutUrl : url

The url to the sign out page

Kind: instance property of authentication
Category: properties

Static members

authentication.defaults : Object

Default plugin options

Kind: static property of authentication
Properties
NameTypeDefaultDescription
redirectstring "/notify"

URL to redirect to after signing in or out

frameClassNamestring

Classes added to the class-property of authenticationFrame

frameNamestring "authentication"

Name used for the authentication panel

Example
WeavyWidget.plugins.authentication.defaults = {
    redirect: '/notify',
    frameClassName: "",
    frameName: "authentication"
};