Webmaker Login UX enables developers to implement a consitent login/logout and signup
flow for webmaker across different websites and apps. This is acheived through the use
of an adapter that handles implementation specific details (modal dialog handling,
angular JS style directive implementation), while the common parts of theimplementation
(state, request handling, analytics, etc) are handled by a core library.
The adapter and all of the dependencies (JS, HTML templates) are built using Browserify
into one package that can be included into the target application’s build system. Custom CSS to
override Makerstrap styles are also included and should be imported into the target application.
Installation
bower install mozilla/webmaker-login-ux
Angular Adapter Usage
Add makerstap in your head <link rel="stylesheet" href="bower_components/makerstrap/dist/makerstrap.complete.min.css">. There are other ways to do this – see the makerstrap docs.
Use the disablepersona attribute to disable login via Persona. (Defaults to false).
wm-password-reset
Configures the password reset modal to display when the page is loaded with the resetCode and uid
search parameters in the url:
<div wm-password-reset></div>
wm-logout
Confugures the element it is applied to to trigger a logout when it is clicked.
<button wm-logout></button>
Plain JS Adapter Usage
Add makerstrap to your app: <link rel="stylesheet" href="bower_components/makerstrap/dist/makerstrap.complete.min.css". There are other ways to do this – see the makerstrap docs.
First you need to create an instance of the WebmakerLogin client:
var auth = new window.WebmakerLogin({
csrfToken: 'csrf', // optional csrf token
showCTA: true // Show a random CTA after signing up for a new account. true/false,
disablePersona: false // Disable login with persona? true/false
});
verified Event
After you initialize the client, the verified event will be emitted after checking the webmaker-login cookie for user data.
If the user is signed-in, then the callback will return an object representing the user.
If the user is signed-out, then the callback will return nothing.
auth.on('verified', function(user) {
if (user) {
console.log('%s is signed-in', user.username);
} else {
console.log('signed-out');
}
});
Create Account
Initiates the account creation process.
auth.create(email_hint, username_hint);
email_hint is an optional parameter to pre-fill the email address for account creation
username_hint is an optional parameter to pre-fill the username for account creation
Login
Initiates the account sign-in process.
auth.login(userid_hint);
userid_hint is an optional parameter to pre-fill the user id for account login
login Event
After you call create() or login() and the user finishes either process, the client will emit a login event with the signed-in users data.
auth.on('login', function(user) {
console.log('%s is signed-in', user.username);
});
Logout
Initiates the account sign-out process.
auth.logout();
logout Event
After you call logout() and the client has successfully cleared the webmaker-login cookie, the client will emit a logout event.
If you run grunt dev, all files and folders will be watched and automatically compiled.
A test server will also be launched at http://localhost:4321 where you can test out the modal dialogs
with fake data.
Add ?uid=user&resetCode=topsecretcode to the url to trigger the password reset flow.
Change the values of uid and resetCode to cause a failed reset request.
Webmaker Login UX
Webmaker Login UX enables developers to implement a consitent login/logout and signup flow for webmaker across different websites and apps. This is acheived through the use of an adapter that handles implementation specific details (modal dialog handling, angular JS style directive implementation), while the common parts of theimplementation (state, request handling, analytics, etc) are handled by a core library.
The adapter and all of the dependencies (JS, HTML templates) are built using Browserify into one package that can be included into the target application’s build system. Custom CSS to override Makerstrap styles are also included and should be imported into the target application.
Installation
Angular Adapter Usage
<link rel="stylesheet" href="bower_components/makerstrap/dist/makerstrap.complete.min.css">. There are other ways to do this – see the makerstrap docs.<link rel="stylesheet" href="bower_components/webmaker-login-ux/dist/css/webmakerLogin.css">.window.angularConfigas an object, and specify acsrfTokenattribute.angular.js,ui-bootstrap,ngWebmakerLogin.jsandngWebmakerLogin.templates.jsare all added to your document.ngWebmakerLoginmodule to your angular app.ngWebmakerLogin Directives
wm-join-webmaker
Configures the join webmaker modal to display when the element it is used on is clicked:
Use the
showctaattribute to define whether or not the welcome to webmaker CTA’s should display after an account is created.wm-signin
Configures the signin modal to display when the element it is used on is clicked
Use the
disablepersonaattribute to disable login via Persona. (Defaults tofalse).wm-password-reset
Configures the password reset modal to display when the page is loaded with the
resetCodeanduidsearch parameters in the url:wm-logout
Confugures the element it is applied to to trigger a logout when it is clicked.
Plain JS Adapter Usage
<link rel="stylesheet" href="bower_components/makerstrap/dist/makerstrap.complete.min.css". There are other ways to do this – see the makerstrap docs.<link rel="stylesheet" href="bower_components/webmaker-login-ux/dist/css/webmakerLogin.css">.<script src="bower_components/webmaker-login-ux/dist/min/webmakerLogin.min.js">.API
Constructor
First you need to create an instance of the WebmakerLogin client:
verifiedEventAfter you initialize the client, the
verifiedevent will be emitted after checking the webmaker-login cookie for user data. If the user is signed-in, then the callback will return an object representing the user. If the user is signed-out, then the callback will return nothing.Create Account
Initiates the account creation process.
Login
Initiates the account sign-in process.
loginEventAfter you call
create()orlogin()and the user finishes either process, the client will emit aloginevent with the signed-in users data.Logout
Initiates the account sign-out process.
logoutEventAfter you call
logout()and the client has successfully cleared the webmaker-login cookie, the client will emit alogoutevent.Development
If you run
grunt dev, all files and folders will be watched and automatically compiled. A test server will also be launched at http://localhost:4321 where you can test out the modal dialogs with fake data.Angular adapter test page: http://localhost:4321/
Plain JavaScript adapter test page: http://localhost:4321/plain
Sign In Options:
Join Webmaker Options:
Password reset
Add
?uid=user&resetCode=topsecretcodeto the url to trigger the password reset flow. Change the values of uid and resetCode to cause a failed reset request.