1
0
mirror of https://github.com/moparisthebest/kaiwa synced 2024-08-13 17:03:51 -04:00
kaiwa/clientapp/pages/signin.js
2013-09-03 15:25:14 -07:00

45 lines
1.0 KiB
JavaScript

/*global app, client*/
"use strict";
var BasePage = require('./base');
var templates = require('../templates');
module.exports = BasePage.extend({
template: templates.pages.signin,
events: {
'submit #loginForm form': 'login'
},
initialize: function (spec) {
this.renderAndBind();
},
login: function (e) {
e.preventDefault();
var jid = this.$('#jid').val();
var password = this.$('#password').val();
var wsURL = this.$('#wsURL').val();
client.connect({
jid: jid,
server: jid.slice(jid.indexOf('@') + 1),
wsURL: wsURL,
credentials: {
password: password
}
});
client.once('auth:success', 'signin', function () {
client.releaseGroup('signin');
app.navigate('/');
});
client.once('auth:failed', 'signin', function () {
client.releaseGroup('signin');
console.log('Failed Auth');
});
return false;
}
});