JS adapter promises have changed
It appears that instead of `.then` and `.catch` you now use `.success` and `.error`. I've updated the examples accordingly.
This commit is contained in:
parent
f490e1fba7
commit
da8ce0026e
1 changed files with 8 additions and 8 deletions
|
@ -28,9 +28,9 @@ The following example shows how to initialize the JavaScript adapter:
|
||||||
<script src="keycloak.js"></script>
|
<script src="keycloak.js"></script>
|
||||||
<script>
|
<script>
|
||||||
var keycloak = Keycloak();
|
var keycloak = Keycloak();
|
||||||
keycloak.init().then(function(authenticated) {
|
keycloak.init().success(function(authenticated) {
|
||||||
alert(authenticated ? 'authenticated' : 'not authenticated');
|
alert(authenticated ? 'authenticated' : 'not authenticated');
|
||||||
}).catch(function() {
|
}).error(function() {
|
||||||
alert('failed to initialize');
|
alert('failed to initialize');
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -102,9 +102,9 @@ token was successfully refreshed and for example display an error to the user if
|
||||||
|
|
||||||
[source,javascript]
|
[source,javascript]
|
||||||
----
|
----
|
||||||
keycloak.updateToken(30).then(function() {
|
keycloak.updateToken(30).success(function() {
|
||||||
loadData();
|
loadData();
|
||||||
}).catch(function() {
|
}).error(function() {
|
||||||
alert('Failed to refresh token');
|
alert('Failed to refresh token');
|
||||||
});
|
});
|
||||||
----
|
----
|
||||||
|
@ -392,9 +392,9 @@ For example:
|
||||||
|
|
||||||
[source,javascript]
|
[source,javascript]
|
||||||
----
|
----
|
||||||
keycloak.loadUserProfile().then(function(profile) {
|
keycloak.loadUserProfile().success(function(profile) {
|
||||||
alert(JSON.stringify(profile, null, " "));
|
alert(JSON.stringify(profile, null, " "));
|
||||||
}).catch(function() {
|
}).error(function() {
|
||||||
alert('Failed to load user profile');
|
alert('Failed to load user profile');
|
||||||
});
|
});
|
||||||
----
|
----
|
||||||
|
@ -413,13 +413,13 @@ For example:
|
||||||
|
|
||||||
[source,javascript]
|
[source,javascript]
|
||||||
----
|
----
|
||||||
keycloak.updateToken(5).then(function(refreshed) {
|
keycloak.updateToken(5).success(function(refreshed) {
|
||||||
if (refreshed) {
|
if (refreshed) {
|
||||||
alert('Token was successfully refreshed');
|
alert('Token was successfully refreshed');
|
||||||
} else {
|
} else {
|
||||||
alert('Token is still valid');
|
alert('Token is still valid');
|
||||||
}
|
}
|
||||||
}).catch(function() {
|
}).error(function() {
|
||||||
alert('Failed to refresh the token, or the session has expired');
|
alert('Failed to refresh the token, or the session has expired');
|
||||||
});
|
});
|
||||||
----
|
----
|
||||||
|
|
Loading…
Reference in a new issue