-
Notifications
You must be signed in to change notification settings - Fork 11
/
LoginCtrl.js
35 lines (30 loc) · 1007 Bytes
/
LoginCtrl.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
'use strict';
angular.module('app').controller('LoginCtrl', function($rootScope, $scope, $uibModal, mafenSession, alertify, PATHS, CODES) {
'ngInject';
$scope.mafenSession = mafenSession;
$scope.user = {};
var onclose = function(e) {
if (e.code !== CODES.wsClosedByUser) {
alertify.alert(
"Lost connection to the server. Maybe you logged in to the game client.",
$rootScope.logout);
}
};
$scope.login = function() {
$scope.mafenSession
.reset()
.connect('ws://mafen.club:8000')
.wsOnClose(onclose);
$scope.loginPromise = $scope.mafenSession.login($scope.user.username, $scope.user.password);
$scope.loginPromise.then(function() {
$uibModal.open({
ariaLabelledBy: 'charlist-modal-title',
ariaDescribedBy: 'charlist-modal-body',
templateUrl: PATHS.views + 'charlist.html',
controller: 'CharListCtrl'
});
}, function() {
alertify.error('Authentication failed');
});
};
});