reset_password.html now redirects browser to URL specified in 'redirect'
uri component (if present).

The component has to be URI encoded. ie (in browser console):

$ encodeURIComponent('http://pvoborni.fedorapeople.org/doc/#!/guide/Debugging')

-->
"http%3A%2F%2Fpvoborni.fedorapeople.org%2Fdoc%2F%23!%2Fguide%2FDebugging"

-->

https://my.freeipa.server/ipa/ui/reset_password.html?redirect=http%3A%2F%2Fpvoborni.fedorapeople.org%2Fdoc%2F%23!%2Fguide%2FDebugging

https://fedorahosted.org/freeipa/ticket/4440
--
Petr Vobornik
From 975c1afb4a96d699a43f9c68af343316659d7c6d Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvobo...@redhat.com>
Date: Wed, 23 Jul 2014 16:53:56 +0200
Subject: [PATCH] webui: add bounce url to reset_password.html

reset_password.html now redirects browser to URL specified in 'redirect'
uri component (if present).

The component has to be URI encoded. ie (in browser console):

$ encodeURIComponent('http://pvoborni.fedorapeople.org/doc/#!/guide/Debugging')

-->
"http%3A%2F%2Fpvoborni.fedorapeople.org%2Fdoc%2F%23!%2Fguide%2FDebugging"

-->

https://my.freeipa.server/ipa/ui/reset_password.html?redirect=http%3A%2F%2Fpvoborni.fedorapeople.org%2Fdoc%2F%23!%2Fguide%2FDebugging

https://fedorahosted.org/freeipa/ticket/4440
---
 install/ui/reset_password.js | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/install/ui/reset_password.js b/install/ui/reset_password.js
index bc08349876ea18d204ce4d6e8ae7724878967620..1afc76eba061a7015d1e817e840177fd60e35160 100644
--- a/install/ui/reset_password.js
+++ b/install/ui/reset_password.js
@@ -114,6 +114,7 @@ RP.on_submit = function() {
     } else {
         RP.reset_form();
         RP.show_success("Password reset was successful.");
+        RP.redirect();
     }
 };
 
@@ -140,6 +141,29 @@ RP.show_success = function(message) {
     $('.alert-success').css('display', '');
 };
 
+RP.parse_uri = function() {
+    var opts = {};
+    if (window.location.search.length > 1) {
+        var couples = window.location.search.substr(1).split("&");
+        for (var i=0,l=couples.length; i < l; i++) {
+            var couple = couples[i].split("=");
+            var key = decodeURIComponent(couple[0]);
+            var value = couple.length > 1 ? decodeURIComponent(couple[1]) : '';
+            opts[key] = value;
+        }
+    }
+    return opts;
+};
+
+RP.redirect = function() {
+
+    var opts = RP.parse_uri();
+    var url = opts['redirect'];
+    if (url) {
+        window.location = url;
+    }
+};
+
 
 RP.init = function() {
 
-- 
1.9.3

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to