PageSourceSearch

https://service-sportprogesundheit.de/js/authentication/authentication.ctrl.js

js service-sportprogesundheit.de collected 2026-10-07 22:32:40 UTC 3,557 bytes, 95 lines download raw bytes

1(function () {
2    'use strict';
3
4    angular
5        .module('app')
6        .controller('AuthenticationCtrl', AuthenticationCtrl);
7    AuthenticationCtrl.$inject = ['$rootScope', '$window', '$location', '$log', '$scope', '$state', '$cookies', 'authService', 'Notifications', 'AccountData', 'Identity', 'Utils'];
8
9    function AuthenticationCtrl($rootScope, $window, $location, $log, $scope, $state, $cookies, authService, Notifications, AccountData, Identity, Utils) {
10        /* jshint validthis:true */
11        var vm = this;
12        vm.title = 'authentication';
13        vm.login = login;
14        vm.getUserName = getUserName;
15        vm.resetPassword = resetPassword;
16
17        vm.error = $state.params.error;
18
19        function getUserName() {
20            return JSON.parse($cookies.get('identity')).Name;
21        }
22
23        function resetPassword() {
24            authService.resetPassword(vm.email).then(function () {
25                Notifications.addSuccessMsg(vm.email, "E-Mail an " + vm.email + " gesendet!");
26
27            }, function (err) {
28                Utils.concatError(err);
29            });
30        }
31
32        function removeStoleIdentity() {
33            localStorage.removeItem('TGSPG_OWNTOKENSTORE');
34            localStorage.removeItem('TGSPG_BACKURL');
35        }
36
37        function login() {
38            vm.dataLoading = true;
39            var user = { userName: vm.email, password: vm.password };
40            authService.login(user).then(function () {
41                removeStoleIdentity();
42                AccountData.getIdentity().then(function (identity) {
43                    $log.debug('Got an identity.');
44                    $log.debug(identity);
45                    if (identity.aud.length > "http:/".length) {
46                        vm.identity = identity;
47                        $cookies.put('identity', JSON.stringify(identity));
48                        
49                        if ($rootScope.homeState) {
50                            $state.go($rootScope.homeState);
51                        } else {
52                            $location.path('/');
53                            $window.location.reload();
54                        }
55                    } else {
56                        $log.error('Identity is broken.');
57                        Notifications.addErrorMsg('', 'Die Anmeldung war nicht erfolgreich!');
58                    }
59                });
60            }, function (err) {
61                Notifications.addErrorMsg("Anmeldung fehlgeschlagen!",
62                    "Der Benutzername oder das Kennwort ist fehlerhaft!"); vm.dataLoading = false;
63            });
64        };
65
66        vm.clearCredentials = function () {
67
68            if (Identity.isIdentityStolen()) {
69                Identity.removeIdentity();
70            }
71
72            AccountData.logout();
73            $cookies.remove('identity');
74            Notifications.addSuccessMsg('', 'Erfolgreich abgemeldet!');
75            $state.go('login');
76        };
77
78        vm.isLogged = function () {
79            return authService.isLoggedIn();
80        }
81
82        vm.isAdmin = function () {
83            return $cookies.get('identity') !== undefined;
84        }
85        vm.isZertifizierungsstellenprofil = function () {
86            return ($state.includes('zertifizierungsstellenprofil-bearbeiten'))
87                || ($state.includes('zertifizierungsstellenprofil-mitarbeiter'))
88                || ($state.includes('zertifizierungsstellenprofil-benutzer'))
89                || ($state.includes('zertifizierungsstellenprofil-vereine'));
90        }
91    }
92
93
94
95})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.