1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 17:02:41 +01:00
phorge-phorge/webroot/rsrc/js/application/auth/behavior-persona-login.js
epriestley 0ce4f6d176 Add Persona auth provider
Summary: Ref T3958. Adds a provider for Mozilla's Persona auth.

Test Plan:
  - Created a Persona provider.
  - Registered a new account with Persona.
  - Logged in with Persona.
  - Linked an account with Persona.
  - Dissolved an account link with Persona.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T3958

Differential Revision: https://secure.phabricator.com/D7313
2013-10-14 14:34:57 -07:00

41 lines
1.1 KiB
JavaScript

/**
* @provides javelin-behavior-persona-login
* @requires javelin-behavior
* javelin-resource
* javelin-stratcom
* javelin-workflow
* javelin-util
*/
JX.behavior('persona-login', function(config) {
JX.Stratcom.listen(
'submit',
'persona-login-form',
function(e) {
e.kill();
navigator.id.request();
});
var onloaded = function() {
// Before installing watch(), log the user out, because we know they don't
// have a valid session if they're hitting this page. If we don't do this,
// Persona may immediately trigger a login event, which prevents the user
// from selecting another authentication mechanism.
navigator.id.logout();
navigator.id.watch({
loggedInUser: null,
onlogin: onlogin,
onlogout: JX.bag
});
};
var onlogin = function(assertion) {
new JX.Workflow(config.loginURI, {assertion: assertion})
.start();
};
var persona_library = 'https://login.persona.org/include.js';
JX.Resource.load(persona_library, onloaded);
});