r77954 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r77953‎ | r77954 | r77955 >
Date:03:05, 7 December 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Added js to log in as a user on the remote wiki
Modified paths:
  • /trunk/extensions/Push/includes/ext.push.tab.js (modified) (history)

Diff [purge]

Index: trunk/extensions/Push/includes/ext.push.tab.js
@@ -46,13 +46,67 @@
4747 else {
4848 sender.innerHTML = sender.innerHTML + '.';
4949 for (first in data.query.pages) break;
50 - getTokenAndContinue( sender, targetUrl, data.query.pages[first] );
 50+ doLoginAndContinue( sender, targetUrl, data.query.pages[first] );
5151 }
5252 }
5353 );
5454 }
5555
56 - function getTokenAndContinue( sender, targetUrl, page ) {
 56+ function doLoginAndContinue( sender, targetUrl, page ) {
 57+ if ( false ) { // TODO
 58+ var name = 'WikiSysop'; // TODO
 59+ var password = 'inurwiki'; // TODO
 60+
 61+ $.post(
 62+ targetUrl + '/api.php',
 63+ {
 64+ 'action': 'login',
 65+ 'format': 'json',
 66+ 'lgname': name,
 67+ 'lgpassword': password,
 68+ },
 69+ function( data ) {
 70+ if ( data.error ) {
 71+ handleError( sender, targetUrl, data.error );
 72+ }
 73+ else {
 74+ if ( data.login.result == "NeedToken" ) {
 75+ confirmLoginTokenAndContinue( sender, targetUrl, page, data.login.token, name, password );
 76+ }
 77+ else {
 78+ getEditTokenAndContinue( sender, targetUrl, page );
 79+ }
 80+ }
 81+ }
 82+ );
 83+ }
 84+ else {
 85+ getEditTokenAndContinue( sender, targetUrl, page );
 86+ }
 87+ }
 88+
 89+ function confirmLoginTokenAndContinue( sender, targetUrl, page, token, name, password ) {
 90+ $.post(
 91+ targetUrl + '/api.php',
 92+ {
 93+ 'action': 'login',
 94+ 'format': 'json',
 95+ 'lgname': name,
 96+ 'lgpassword': password,
 97+ 'lgtoken': token
 98+ },
 99+ function( data ) {
 100+ if ( data.error ) {
 101+ handleError( sender, targetUrl, data.error );
 102+ }
 103+ else {
 104+ getEditTokenAndContinue( sender, targetUrl, page );
 105+ }
 106+ }
 107+ );
 108+ }
 109+
 110+ function getEditTokenAndContinue( sender, targetUrl, page ) {
57111 $.getJSON(
58112 targetUrl + '/api.php',
59113 {
@@ -73,12 +127,8 @@
74128 }
75129 }
76130 );
77 - }
 131+ }
78132
79 - function doLoginAndContinue() {
80 -
81 - }
82 -
83133 function doPush( sender, targetUrl, page, token ) {
84134 var summary = mediaWiki.msg( 'push-import-revision-message' );
85135 summary = summary.replace( '$1', $('#siteName').attr('value') );

Status & tagging log