Login from web sites

From Complete Cyclos documentation wiki
Jump to: navigation, search

It is very easy to add the Cyclos login form on external web sites, for example, with the project web site.

It can be done in some steps:

  1. Include a script from <cyclos root url>/externalLogin.js in your page. For example: http://www.cyclos.org/cyclos_en/externalLogin.js
  2. Create an HTML element which will contain the login form iframe. It may be any HTML container tag (table cell, div, paragraph...) with an unique id.
  3. Add a JavaScript event listener to the body load event which invokes a function defined by the externalLogin.js file: includeCyclosLogin(<container id>, [after logout url]).

For example, if you have an HTML element identified by 'loginContainer' and want to return to the same url as your site after logout, use: includeCyclosLogin('loginContainer', location.href). When the second argument is omitted, after logging out, the default Cyclos login page is shown.

The login form is rendered inside an IFrame, which has its dimensions set to the same value as the container element dimensions. This means that the container element should be large enough to display the entire login form. An automatic resize cannot be done because normally Cyclos and the web server will run on distinct domains, and it's illegal in JavaScript that two frames on distinct domains interact with each other.