OWL ITS + 탐지시스템(인터넷 진흥원)
이민희
2021-12-02 616d76059d929650113f8a4ec750d86c4647b064
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/**
 * Created by wisestone on 2018-10-16.
 */
'use strict';
 
define([
        'app',
        'angular'
    ],
    function (app, angular) {
        app.controller('userModifyPasswordController', ['$scope', '$rootScope', '$log', '$resourceProvider', 'User', '$uibModalInstance', 'parameter', 'SweetAlert', '$filter',
            function ($scope, $rootScope, $log, $resourceProvider, User, $uibModalInstance, parameter, SweetAlert, $filter) {
 
                $scope.fn = {
                    cancel: cancel, //  팝업 창 닫기
                    formSubmit: formSubmit, //  폼 전송
                    formCheck: formCheck   //  폼 체크
                };
 
                $scope.vm = {
                    form: {
                        id : parameter.id,
                        currentPassword : "",   //  현재 비밀번호
                        password : "",  //  비밀번호
                        passwordConfirm : ""    //  신규 비밀번호 확인
                    }
                };
 
                //  폼 체크
                function formCheck(formInvalid) {
                    if (formInvalid) {
                        return true;
                    }
 
                    if (!$rootScope.isDefined($scope.vm.form.currentPassword) || !$rootScope.isDefined($scope.vm.form.password) || !$rootScope.isDefined($scope.vm.form.passwordConfirm)) {
                        return true;
                    }
 
                    if ($scope.vm.form.password.length < 4) {
                        return true;
                    }
 
                    if ($scope.vm.form.passwordConfirm.length < 4) {
                        return true;
                    }
 
                    if ($scope.vm.form.password !== $scope.vm.form.passwordConfirm) {
                        return true;
                    }
 
                    return false;
                }
 
                //  폼 전송
                function formSubmit() {
                    $rootScope.spinner = true;
 
                    var content = {
                        id : $scope.vm.form.id,
                        currentPassword : CryptoJS.SHA512($scope.vm.form.currentPassword).toString(),
                        password : CryptoJS.SHA512($scope.vm.form.password).toString(),
                        passwordConfirm : CryptoJS.SHA512($scope.vm.form.passwordConfirm).toString()
                    };
 
                    User.modifyPassword($resourceProvider.getContent(
                        content,
                        $resourceProvider.getPageContent(0, 0))).then(function (result) {
                        if (result.data.message.status === "success") {
                            SweetAlert.swal($filter("translate")("users.completedPasswordChange"), result.data.message.message, "success"); // "비밀번호 변경 완료"
                            $scope.fn.cancel();
                        }
                        else {
                            SweetAlert.swal($filter("translate")("users.failedPasswordChange"), result.data.message.message, "error"); // "비밀번호 변경 실패"
                        }
 
                        $rootScope.spinner = false;
                    });
                }
 
                //  팝업 창 닫기
                function cancel() {
                    $rootScope.$broadcast("closeLayer");    //  팝업이 열리고 나서 js-multi, js-single 등에서 body 이벤트가 날아가는 현상 수정
                    $uibModalInstance.dismiss('cancel');
                    $(document).unbind("keydown");  //  단축키 이벤트 제거
                }
            }]);
    });