future.then(this, function gotConfigObject() {
		var result = checkResult(future), path, newPath, scheme;
		if (result.returnValue === true) {
			this.config = result.config;
			this.config.ignoreSSLCertificateErrors = args.ignoreSSLCertificateErrors;

			urlScheme = urlScheme || this.config.urlScheme;
			url = url || this.config.url;
			userAuth.username = userAuth.username || this.config.username;
			if (scheme && !scheme.oauth) {
				Log.debug("Overwiting authToken with username from db: ", userAuth.username);
				userAuth.authToken = "Basic " + Base64.encode(userAuth.username + ":" + args.password);
			}
		}
		scheme = UrlSchemes.urlSchemes[urlScheme];

		//use forced scheme to resolve here, otherwise search strings in URL.
		url = UrlSchemes.resolveURL(url, userAuth.username, "checkCredentials", urlScheme) || url;

		if (url) {
			path = url;
		} else {
			Log.log("No URL. Can't check credentials!");
			outerfuture.exception = new Transport.BadRequestError("No URL. Can't check credentials!");
			return;
		}

		//Do this here to prevent users from setting credentials with 2.2.4 app.
		if (scheme && scheme.oauth && !userAuth.oauth) {
			Log.log("Accounts needs oAuth, but none supplied.");
			outerfuture.exception = new Transport.BadRequestError("Accounts needs oAuth, but none supplied. Change credentials won't work for oauth accounts in webOS 2.x.");
			return;
		}

		// Test basic authentication. If this fails username and or password is wrong
		future.nest(
			AuthManager.checkAuth(
				userAuth,
				path,
				-1,
				{
					userAuth: userAuth,
					ignoreSSLCertificateErrors: this.config.ignoreSSLCertificateErrors
				}
			)
		);
	});
Beispiel #2
0
exports.run=function(req,res){
	rw.sess.start(req,res);
	if(!common.checkAuth(req,res)){
		req=null;
		res=null;
		return;
	}
	if(!req.session.data['rouwan_path']){
		req.session.data['rouwan_path']=__dirname;
	}
	rw.http.zout(
		rw.t.render(
			__dirname+'/../template/page.html',{'TITLE':'Code - ','LINK':'<script type="text/javascript" src="./js/code.js?sp=2"></script><script type="text/javascript" src="./js/ace/ace.js?sp=3"></script><link href="./css/code.css?sp=2" rel="stylesheet" type="text/css" />','MCUR2':' cur','WRAPPER':rw.t.render(__dirname+'/../template/code.html',{'PATH':req.session.data['rouwan_path']}),'V':rw.config.version}
		),
		req,
		res
	);
	req=null;
	res=null;
};
Beispiel #3
0
exports.run=function(req,res){
	rw.sess.start(req,res);
	if(!common.checkAuth(req,res)){
		req=null;
		res=null;
		return;
	}
	var t=rw.util.s2t(process.uptime());
	var up=t[0]+'d '+t[1]+'h '+t[2]+'m '+t[3]+'s';
	t=rw.util.s2t(os.uptime());
	var osup=t[0]+'d '+t[1]+'h '+t[2]+'m '+t[3]+'s';
	var lav=os.loadavg();
	lav[0]=lav[0].toFixed(2);
	lav[1]=lav[1].toFixed(2);
	lav[2]=lav[2].toFixed(2);
	var tthi=' class="hide"',tspr='-',tspra='-',long='-';
	if(rw.config.backstage.switch.timetag){
		tthi='';
		if(rw.timeTag.c>0){
			tspr='<b>'+(rw.timeTag.t/rw.timeTag.c).toFixed(5)+' ms</b>';
			tspra='<b>'+(rw.timeTag.m.t/rw.timeTag.m.c).toFixed(5)+' ms, '+(rw.timeTag.h.t/rw.timeTag.h.c).toFixed(5)+' ms, '+(rw.timeTag.d.t/rw.timeTag.d.c).toFixed(5)+' ms</b>';
			long='<b>'+(rw.timeTag.list[0].time).toFixed(5)+'ms, '+rw.timeTag.list[0].url+'</b>';
		}
	}
	rw.http.zout(
		rw.t.render(
			__dirname+'/../template/page.html',{'LINK':'<script type="text/javascript" src="./js/index.js?sp=2"></script><script type="text/javascript" src="./js/ace/ace.js?sp=3"></script><link href="./css/index.css?sp=2" rel="stylesheet" type="text/css" />','MCUR1':' cur','V':rw.config.version,'WRAPPER':rw.t.render(__dirname+'/../template/index.html',{'TTHI':tthi,'TSPR':tspr,'TSPRA':tspra,'LONG':long,'NV':process.version,'PID':process.pid,'TITLE':process.title,'MEM':parseInt(process.memoryUsage().rss/1024/1024)+' MB','MEMP':Math.ceil(process.memoryUsage().rss*100/os.totalmem())+'%','SMEM':parseInt(os.totalmem()/1024/1024)+' MB','UP':up,'LAV':lav.join(', '),'FRM':parseInt(os.freemem()/1024/1024)+' MB','OSUP':osup,'OID':'rw.session.'+req.session.sid})}
		),
		req,
		res
	);
	req=null;
	res=null;
	t=null;
	up=null;
	lav=null;
	osup=null;
};
Beispiel #4
0
 /*
 * userApi.checkAuth
 */
 function checkAuth (next) {
     console.log('userApi.checkAuth');
     var params = {
         token: 'spam',
         login: '******',
         password: '******',
     };
     var data = {
         params:[params]
     };
     userApi.checkAuth(data, function(err, result) {
         if (! err) {
             test.fail(result);
         } else {
             test.throws(
                 function() {
                     throw new Error(err);
                 },
                 Error
             );
         }
         next();
     });
 },