icon
Avatar
tupai86
Posts: 1
EDIT -> I tried to place codes inside [ code ] tag, but unfortunately none works


Ext.define('OculusTaskmaster.controller.Authentication', {
extend: 'Ext.app.Controller',
require: [ 'OculusTaskmaster.model.User' ],
config: {
refs: {
login: 'login',
main: 'main'
},
control: {
login: {
loginButtonCommand: 'onLoginButtonCommand'
}
}
},
init: function() {
Bancha.getStub('User').login({}, {
success: function(result, response) {
if (result.success) {
console.log('Already Authenticated');
} else {
console.log('Not Yet Authenticated!!');
var login = Ext.create('OculusTaskmaster.view.Login', {});
login.show();
}
}
});

this.on({
loggedin: {
fn: this.onLoggedIn,
scope: this
}
});
},
onLoginButtonCommand: function() {
var me = this;
var login = me.getLogin();
var values = login.getValues();

Bancha.getStub('User').login(values, {
success: function(result, response) {
if (result.success) {
console.log('Authenticated');

login.hide();

var user = Ext.create('OculusTaskmaster.model.User', result.data);
me.fireEvent('loggedin', user, me);
} else {
console.log('Login Failed!!');
}
},
failure: function(result, response) {
console.log('fail');
}
});
},
onLoggedIn: function(userRecord, app) {
this.active_user = userRecord;

var aor = Ext.getStore('AreaOfResponsibilities').load();

console.log(aor);
}
});

on the onLoggedIn(), the line:

var aor = Ext.getStore('AreaOfResponsibilities').load();

is giving out console log message "Please Login First".. Please help, i have been trying to solve this for hours :confused: :cry:
2015-09-01 11:42
icon Please login to reply or post!