KEYCLOAK-2821 : Add the adapter option

You just can add an 'adapter' option to the kc.init() function like :

kc.init({adapter: "default | cordova"});

This will allow the users to choose the adapter they want. They can force the use of the default adapter even if they are using cordova or use the cordova adapter even if they are using a regular desktop.

If you omit this parameter, it just fallback to the old way. So, if you are under cordova it will run the cordova adapter and if you are under a desktop, it will load the default adapter instead.

Hope this can help.
This commit is contained in:
Jonathan Masmejean 2016-04-14 11:59:34 +02:00
parent 9e3fa4b566
commit 93b54ce13a

View file

@ -34,11 +34,16 @@
kc.init = function (initOptions) { kc.init = function (initOptions) {
kc.authenticated = false; kc.authenticated = false;
if (initOptions && initOptions.adapter === 'cordova') {
if (window.Cordova) { adapter = loadAdapter('cordova');
adapter = loadAdapter('cordova'); } else if (initOptions && initOptions.adapter === 'default') {
} else {
adapter = loadAdapter(); adapter = loadAdapter();
} else {
if (window.Cordova) {
adapter = loadAdapter('cordova');
} else {
adapter = loadAdapter();
}
} }
if (initOptions) { if (initOptions) {