Sha256: cd8d18885cf7fd8df78efde458b7b56ee04f983c328a99e9964d1c89ff18d139

Contents?: true

Size: 1.48 KB

Versions: 3

Compression:

Stored size: 1.48 KB

Contents

function afterJanrainLogin(result, path)
{
  path = path || "/users/sign_in";

  // create form
  var form  = $('<form accept-charset="UTF-8" action="' + path + '" method="post" id="capturable-inject-form"></form>')
  
  // create hidden div in form
  var hidden_els = $('<div style="margin:0;padding:0;display:inline"></div>')

  // add utf
  hidden_els.append('<input name="utf8" type="hidden" value="✓">')

  // grab forgery token
  var token_name = $("meta[name='csrf-param']").attr('content')
  var token_val = $("meta[name='csrf-token']").attr('content')
  if(token_name && token_val)
  {
    hidden_els.prepend('<input name="'+token_name +'" type="hidden" value="'+token_val+'">')
  }

  // append hidden els to form
  form.append(hidden_els)

  // add oauth code to form
  form.append('<input id="authorization-code" name="code" type="hidden" value="'+result.authorizationCode+'">')

  janrain.capture.ui.modal.close();
  
  $('body').append(form);
  form.submit()
}

function janrainCaptureWidgetOnLoad() {
  
  // these settings will always be the same
  janrain.settings.capture.flowName = 'signIn';
  janrain.settings.capture.responseType = 'code';
  
  // these settings are never used but crashes the widget if not present
  janrain.settings.capture.redirectUri = 'http://stupidsettings.com';
  
  // go go widget go
  janrain.capture.ui.start();
  janrain.events.onCaptureLoginSuccess.addHandler(afterJanrainLogin);
  janrain.events.onCaptureRegistrationSuccess.addHandler(afterJanrainLogin);
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
devise_capturable-0.0.10 lib/assets/javascripts/devise_capturable.js
devise_capturable-0.0.9 lib/assets/javascripts/devise_capturable.js
devise_capturable-0.0.8 lib/assets/javascripts/devise_capturable.js