diff --git a/lib/browserid/views.js b/lib/browserid/views.js index f1d582c4642fc08d37682c87b8c910c1346429f1..de23cb846c48ce64ea3eb2bfe02fd8e57939e8d9 100644 --- a/lib/browserid/views.js +++ b/lib/browserid/views.js @@ -47,6 +47,10 @@ exports.setup = function(app) { }); }); + app.get("/authenticate_with_primary", function(req,res, next) { + res.render('authenticate_with_primary.ejs', { layout: false }); + }); + app.get('/', function(req,res) { res.render('index.ejs', {title: 'A Better Way to Sign In', fullpage: true}); }); diff --git a/resources/static/auth_with_idp/main.js b/resources/static/auth_with_idp/main.js new file mode 100644 index 0000000000000000000000000000000000000000..ee08277d3d1d334871655593183136bcc445af7f --- /dev/null +++ b/resources/static/auth_with_idp/main.js @@ -0,0 +1,7 @@ +var wc = WinChan.onOpen(function(origin, args, cb) { + if (window.location.hash === '#complete') cb(); + else { + wc.detach(); + window.location = args; + } +}); diff --git a/resources/static/pages/signup.js b/resources/static/pages/signup.js index 1a1853470c829f8cce8ba3b2ca75679d66713c27..0e327c8d0b0d78c3a2d9a77bae2051a6d032f96a 100644 --- a/resources/static/pages/signup.js +++ b/resources/static/pages/signup.js @@ -62,7 +62,7 @@ BrowserID.signUp = (function() { var url = helpers.toURL(verifyURL, { email: verifyEmail, - return_to: "https://browserid.org/idp_auth_complete" + return_to: "https://browserid.org/authenticate_with_primary#complete" }); // XXX: we should use winchan (and send user to a page that redirects to primary)! @@ -78,11 +78,13 @@ BrowserID.signUp = (function() { // silently provision again! success means the users is signed up, failure // means there was an auth problem. they can try again? var win = winchan.open({ - url: url, + url: "https://browserid.org/authenticate_with_primary", // This is the relay that will be used when the IdP redirects to sign_in_complete relay_url: "https://browserid.org/relay", - window_features: "width=700,height=375" + window_features: "width=700,height=375", + params: url }, primaryAuthComplete); + oncomplete && oncomplete(); } diff --git a/resources/views/authenticate_with_primary.ejs b/resources/views/authenticate_with_primary.ejs new file mode 100644 index 0000000000000000000000000000000000000000..bfdc57972a3d2e9d3c08ac4ec679030436bf7d1c --- /dev/null +++ b/resources/views/authenticate_with_primary.ejs @@ -0,0 +1,9 @@ +<!doctype html> +<html> +<head> + <meta charset="utf-8"> + <title>Browser ID</title> + <script type='text/javascript' src='https://browserid.org/lib/winchan.js'></script> + <script type='text/javascript' src='https://browserid.org/auth_with_idp/main.js'></script> +</head> +</html>