login anonymous openfire - openfire

I followed this :
Anonymous Login in Openfire with Strophe
i put the domain as the username and password null. The openfire propertie xmpp.auth.anonymous = true
i tried many configurations e Nothing works. What am i missing ?
I´m using backbone and underscore. here is my code
_.extend(Chat.prototype, Backbone.Events, {
connect : function() {
var self = this;
this.connection = new Strophe.Connection(BOSH_SERVICE);
this.connection.connect('brent029', null, function(status) {
self.onConnect(status);
});
},
onConnect : function(status) {
switch(status) {
case Strophe.Status.CONNECTED:
this.sendPresConference();
break;
default:
break;
}
},
sendPresConference : function(){
this.connection.send(
$pres({
to : 'room#conference_service/nick'
})
.c('x',{
xmlns : Strophe.NS.MUC
}).tree()
);
},

I solved it.
openfire have a property sasl.mechs
the value of this property it was "PLAIN".
i changed the value to "ANONYMOUS,PLAIN".
Then, i restarted the openfire and now works fine.

Related

Ti.Media.showCamera not showing even if camera permissions are granted Android 6.0 Titanium

My development environment is mac osx, appcelerator sdk 5.3.0 and testing on google nexus Android 6.0. Ti.Media.showCamera not opening camera even if permissions are granted. Here is my code
function openCamera(parms) {
if (Ti.Media.hasCameraPermissions) {
Ti.API.error("Yes has camera permission");
Ti.Media.showCamera({
success : function(event) {
parms.source.image = newBlob;
},
cancel : function() {
Ti.API.error("User cancelled pictur selection");
},
error : function(error) {
var a = Ti.UI.createAlertDialog({
title : 'Camera Error'
});
if (error.code == Ti.Media.NO_CAMERA) {
a.setMessage("No Camera Found!");
} else {
a.setMessage('Unexpected Error: ' + error.code);
}
a.show();
},
mediaTypes : [Ti.Media.MEDIA_TYPE_PHOTO],
animated : true,
autoHide : true,
allowEditing : true,
saveToPhotoGallery : false,
showControls : true
});
} else {
Ti.API.error("No camera permission. Asking for Permission");
Ti.Media.requestCameraPermissions(function(e) {
Ti.API.error(JSON.stringify(e));
if (e.success === true) {
openCamera(parms);
} else {
alert("Access denied, error: " + e.error);
}
});
}
};
In console log this displayed
Yes has camera permission
[WARN] : InputEventReceiver: Attempted to finish an input event but
the input event receiver has already been disposed.
Would someone point me out what is wrong here.
Hiii I think you are missing brackets after hasCameraPermissions. hasCameraPermissions() is a method defined inside Ti.Media.
Use it like this:
if(hasCameraPermissions()){
//Do you code.....
}

Add Login provider to meteor

I need to use an in-house user management system to authenticate my users. This system also holds the user's membership to groups and roles and tenants which is most useful when doing the authorization stuff.
I looked at the code for accounts-persona but it does not work for me. Hence I deduce that I am doing something wrong.
On the server there is a new LoginHandler:
Meteor.startup( function () {
var config = Accounts.loginServiceConfiguration.findOne( {service: 'sertal'} );
if ( !config ) {
Accounts.loginServiceConfiguration.insert( { service: 'sertal' } );
}
} );
Accounts.registerLoginHandler( function ( options ) {
if ( !options.sertal && !options.assertion )
return undefined; // don't handle
var url = "http://dev.sertal.ch/checkCredential";
var request = {
params: {
uname: options.email,
pword: options.password
}
};
var result = Meteor.http.get( url, request );
if ( result.statusCode !== 200 ) {
throw new Meteor.Error( Accounts.LoginCancelledError.numericError, 'Sertal Login Failed' );
} else {
var user = result.data.userrec;
user.groups = result.data.grprec;
user.id = user._id;
return Accounts.updateOrCreateUserFromExternalService( 'sertal', user );
}
} );
On the client I use this code after the login button has been pressed:
Accounts.callLoginMethod( {
methodName: 'login',
methodArguments: {sertal: true,
email: $( '#sertal-email' ).val(),
password: $( '#sertal-password' ).val(),
resume: false
},
userCallback: function ( error ) {
if ( error ) {
console.log( "error: " + error );
} else {
$( "#sertalLoginFormDiv" ).dropdown( 'toggle' );
}
}
} );
But it does not trigger the LoginHandler. There must be something missing but I can't figure it out.
I could not find any documentation on the subject. An answer could also be to point out some documentation which explains the process.
Based on my testing, the methodArguments must be an array of objects.
Also, from what I see in the logs, if methodArguments object includes a password at the root of the object, then Meteor throws an error with "Failed Login { type: 'password',..."
I was able to make this work by putting all of the handler's arguments as part of an object.
Something like this, on the client:
loginRequest = {myLogin:{email: email, password: password}};
Accounts.callLoginMethod({
methodArguments: [loginRequest],
userCallback: callback
});
When executed on the client, meteor calls my server code:
Accounts.registerLoginHandler( function("someName", loginRequest{
if(loginRequest.myLogin){
// I get the loginRequestObject, and can attempt to sign in...
}
});
Note, I am using Meteor 1.0.

How to execute code before store configuration takes effect?

In our app we rely on the sessionStorage for persistence. However on mobile Safari the sessionStorage is not available when browsing in private mode.
However, for those customers using Safari in private mode it's ok to switch to an in-memory approach. Our app continues to be usable to some extend (you will lose data when you refresh the browser but since it's a single page application you never have to refresh anyway).
The fix was quite easy to do in development mode. However, after running a production build I faced a huge problem.
So, code is worth a thousand words. Here is what we currently use:
index.html
//...
<script type="text/javascript">
var isSessionStorageAvailable = true;
var storage = window.sessionStorage;
if (typeof window.sessionStorage == 'undefined' || window.sessionStorage === null) {
isSessionStorageAvailable = false;
} else try {
storage.setItem('__ccTest', '__ccTest');
} catch (err) {
isSessionStorageAvailable = false;
}
</script>
<script id="microloader" type="text/javascript" src="../sencha/microloader/development.js"></script>
//...
myStore.js
Ext.define('App.store.Quote', {
extend: 'Ext.data.Store',
requires: ['App.model.QuoteItem','Ext.data.proxy.SessionStorage'],
config :{
model: 'App.model.QuoteItem',
autoLoad: true,
autoSync: true,
identifer: 'uuid',
proxy:{
type: isSessionStorageAvailable ? 'sessionstorage' : 'memory',
id:'ccCart'
}
},
//...
So, before sencha get's loaded we first check for the sessionStorage and set a global variable. So at the time when the store file loads the right configuration is picked up.
However, I really dislike this solutions as I had to alter the index.html file. In development mode you can just write this check anywhere in the app.js file because all the other files are loaded afterwards. But in production that's not the case. So I wonder how would you do that properly without altering the index.html file?
UPDATE
I also tried to use the applier like this:
applyProxy: function(proxy, oldProxy){
proxy.type = 'sessionstorage';
var storage = window.sessionStorage;
if (typeof window.sessionStorage == 'undefined' || window.sessionStorage === null) {
proxy.type = 'memory';
} else try {
storage.setItem('__ccTest', '__ccTest');
} catch (err) {
proxy.type = 'memory';
}
this.callParent([proxy, oldProxy]);
}
However, the first time some code calls sync() on this store it raises an error inside the sencha framework:
It's inside the sync method of the store class on this line (it's from the minified source, sorry):
d.getProxy().batch({operations: b,listeners: d.getBatchListeners()})
It raises an error because getProxy() returns undefined. So it seems as if the applier didn't work :(.
Use the applier...
Ext.define('App.store.Quote', {
extend : 'Ext.data.Store',
requires : ['App.model.QuoteItem', 'Ext.data.proxy.SessionStorage'],
config : {
model : 'App.model.QuoteItem',
autoLoad : true,
autoSync : true,
identifer : 'uuid',
proxy : {
id : 'ccCart'
}
},
applyProxy : function (config, oldProxy) {
config.type = isSessionStorageAvailable ? 'sessionstorage' : 'memory';
return this.callParent([config, oldProxy]);
}
});
Just create your store like so :
Ext.define('App.store.Quote', {
extend: 'Ext.data.Store',
requires: ['App.model.QuoteItem','Ext.data.proxy.SessionStorage'],
config :{
model: 'App.model.QuoteItem',
autoLoad: true,
autoSync: true,
identifer: 'uuid'
}
And then, whenever you check if sessionStorage is available, then just do
myStore.setProxy({
type: isSessionStorageAvailable ? 'sessionstorage' : 'memory',
id:'ccCart'
});
Hope this helps
Are you sure the else..try brackets aren't causing issues (JSHint was complaining)?
var isSessionStorageAvailable = true;
var storage = window.sessionStorage;
if (typeof window.sessionStorage == 'undefined' || window.sessionStorage === null) {
isSessionStorageAvailable = false;
} else {
try {
storage.setItem('__ccTest', '__ccTest');
} catch (err) {
isSessionStorageAvailable = false;
}
}

File upload field in EXTJS MVC

Am having a form which consists of various text fields and combo boxes, along with a fileupload field. the file is being uploaded successfully, but when am trying to access the other form fields, they are not seen in the post parameters in the firebug. The code for the controller is given below:
uploadFile : function(button) {
**var form = button.up('form');
var Title = form.down('Title');
console.log(Title);** // This returns null
if (form.getForm().isValid()) {
form.getForm().submit({
url : 'data/Downloads.aspx',
waitMsg : 'Saving the file...',
params : {
mode : 'UPLOADFILE',
client : SYSTEM.CLIENT
},
success : function(f, a) {
Ext.Ajax.request({
url : 'data/Downloads.aspx',
params : {
mode : 'SAVE',
fileName : a.result.fileName
},
success : function() {
this.mWin = Ext.create('Campus.view.GenMessage');
this.mWin.addMessage(true, LANG.SUCT, LANG.SUCTxt2);
},
failure : function() {
}
});
},
failure : function() {
}
})
}
},
How do i access the other form fields and send it to the server.
I don't quite follow what you are doing. You seem to submit the form and then you are doing an ajax call to the server ???
Regardless, all form fields are sent to the server together with the file input. The framework does not use ajax to submit the form as usual because of the file upload, see the docs on this: http://docs.sencha.com/ext-js/4-1/#!/api/Ext.form.Basic-method-hasUpload
Thanks you for your guidance dbrin.
Actually, i was trying to uplaod a document, and at the same time save the information regarding the file in the database. And, thats why i was trying to make an AJAX request. But, here is what i did:
uploadFile : function(button) {
var form = button.up('form');
if (form.getForm().isValid()) {
form.getForm().submit({
url : 'data/Downloads.aspx',
waitMsg : 'Saving the file...',
params : {
mode : 'UPLOADFILE',
client : SYSTEM.CLIENT
},
success : function(form, a) {
this.mWin = Ext.create('App.view.GenMessage');
this.mWin.addMessage(true, LANG.SUCT, LANG.SUCTxt1);
},
failure : function() {
}
})
}
},

How to make a remote connection with database using sencha touch

How to make a remote connection with database using sencha touch
I mean, how do you connect submitting the form to a remote database ?
How do you get the response from database that your form has been submitted successfully ?
You can do it by making an Ext.Ajax request.
Let's assume that your form has 3 fields:-
Name (textfield)
Password (passwordfield)
Age (numberfield)
You will get those fields values like shown below,
.....
.....
// form code ...
{
xtype:'button',
id:'submitBtn',
text:'Submit',
ui:'confirm',
listeners : {
tap : function() {
var form = Ext.getCmp('form-id');
var values = form.getValues();
Ext.Ajax.request({
url: 'http://www.servername.com/insert.php',
params: values,
success: function(response){
var text = response.responseText;
Ext.Msg.alert('Success', text);
}
failure : function(response) {
Ext.Msg.alert('Error','Error while submitting the form');
console.log(response.responseText);
}
});
}
}
....
....
Now, at the server side, your insert.php code will make a connection with your database and insert the values & get the response back to the user.
<?php
$con = mysql_connect("server","username","password");
mysql_select_db('database_name',$con);
$insertQry = "INSERT INTO tableName(name,password,age) VALUES ('".$_POST['name']."','".$_POST['password']."','".$_POST['age']."')";
if(mysql_query($insertQry))
{
echo('success');
}
else
{
echo('failure' . mysql_error());
}
?>