From dd1e5b5c0fe737326d1c5e95a7c343d827364e1e Mon Sep 17 00:00:00 2001 From: stianst Date: Fri, 9 Feb 2018 08:47:49 +0100 Subject: [PATCH] Fix JS console update profile --- .../js-console/src/main/webapp/index.html | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/examples/js-console/src/main/webapp/index.html b/examples/js-console/src/main/webapp/index.html index 3b293f2707..3cb65e01d4 100644 --- a/examples/js-console/src/main/webapp/index.html +++ b/examples/js-console/src/main/webapp/index.html @@ -25,9 +25,11 @@ + + @@ -37,6 +39,8 @@ + +

Result

@@ -55,6 +59,27 @@ }); } + function updateProfile() { + var url = keycloak.createAccountUrl().split('?')[0]; + var req = new XMLHttpRequest(); + req.open('POST', url, true); + req.setRequestHeader('Accept', 'application/json'); + req.setRequestHeader('Content-Type', 'application/json'); + req.setRequestHeader('Authorization', 'bearer ' + keycloak.token); + + req.onreadystatechange = function () { + if (req.readyState == 4) { + if (req.status == 200) { + output('Success'); + } else { + output('Failed'); + } + } + } + + req.send('{"email":"myemail@foo.bar","firstName":"test","lastName":"bar"}'); + } + function loadUserInfo() { keycloak.loadUserInfo().success(function(userInfo) { output(userInfo);