Skip to content

Instantly share code, notes, and snippets.

@pbedat
Created July 6, 2014 11:51
Show Gist options
  • Select an option

  • Save pbedat/3638901e249ebbe4e276 to your computer and use it in GitHub Desktop.

Select an option

Save pbedat/3638901e249ebbe4e276 to your computer and use it in GitHub Desktop.
angular.module("xSources.Security").directive("xsLoginForm", function (AuthenticationApi) {
return {
restrict: "EA",
controller: function ($scope) {
$scope.user = {};
AuthenticationApi.initialize();
$scope.show = false;
$scope.$on("authentication:required", function () {
$scope.show = true;
});
$scope.login = function () {
AuthenticationApi.login($scope.user.name, $scope.user.pass);
};
$scope.$on("authentication:denied", function () {
$scope.message = "Anmeldung fehlgeschlagen";
});
$scope.$on("authenticatoin:failed", function () {
$scope.message = "Während der Anmeldung trat ein Fehler auf";
});
$scope.$on("authentication:granted", function (ev, session) {
$scope.message = "Anmeldung erfolgreich";
angular.module("dummy-app").constant("SESSION", session);
angular.bootstrap($("#main-app"), ["dummy-app"]);
});
},
templateUrl: "/Templates/Login.html",
link: function (scope, element, attrs) {
scope.$watch("show", function (show) {
element.toggle(show);
});
}
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment