Created
July 6, 2014 11:51
-
-
Save pbedat/3638901e249ebbe4e276 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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