PageSourceSearch

https://ism.gov.in/Assets/js/support/auth.js?v=1790265346

js ism.gov.in collected 2026-09-24 10:25:59 UTC 6,433 bytes, 193 lines download raw bytes

1/*
2    Author : Rajat Rai
3*/
4
5var LoginController = {
6    
7    // Login Page
8    login: function () {
9
10        // Encryption of Login Form Data
11        document.getElementById("loginForm").addEventListener("submit", function(e) {
12            var username = document.getElementById("Username").value;
13            var password = document.getElementById("Password").value;
14            var captcha = document.getElementById("Captcha").value;
15            var loginToken = document.getElementById("loginSection").getAttribute("data-secret-token");
16
17            if(username == "" || password == "" || captcha == ""){
18                return false;
19            }
20
21            if(typeof loginToken === "undefined" || loginToken === "") {
22                return false;
23            }
24
25            var encryptedUsername = CryptoJS.AES.encrypt(username, loginToken).toString();
26            var encryptedPassword = CryptoJS.AES.encrypt(password, loginToken).toString();
27
28            document.getElementById("Username").value = encryptedUsername;
29            document.getElementById("Password").value = encryptedPassword;
30
31            return true;
32        });
33
34        // Clear Field
35        $(document).ready(function()
36        {
37            $("#Username").val("");
38            $("#Password").val("");
39            $("#Captcha").val("");
40        });
41
42        // Hide Message After Every 10s
43        setTimeout(function() {
44            $("#login-error-message").hide();
45        }, 10000);
46
47
48        // Password hide and unhide
49        $(document).ready(function () {
50            $("#togglePassword").on("click", function () {
51                const passwordInput = $("#Password");
52                const type = passwordInput.attr("type") === "password" ? "text" : "password";
53                passwordInput.attr("type", type);
54
55                $(this).toggleClass("fa-eye");
56                $(this).toggleClass("fa-eye-slash");
57            });
58        });
59
60    },
61
62    // Verify OTP Page
63    otp: function () {
64
65        // Resend Timer
66        resendTimer();
67        function resendTimer(){
68            let timeLeft = 60;
69            $("#timer").text(timeLeft + " seconds");
70
71            let interval = setInterval(function () {
72                timeLeft--;
73                $("#timer").text(timeLeft + " seconds");
74
75                if (timeLeft <= 0) {
76                    clearInterval(interval);
77                    $("#resend-timer-div").hide();
78                    $("#resend-otp-btn").removeClass("disabled-button");
79                }
80            }, 1000);
81        };
82
83        // Resend OTP
84        $("#resend-otp-btn").click(function(){
85            $('#resend-otp-btn').addClass("disabled-button");
86            let data = $("#resend-otp-btn").attr("data-itemid");
87            $.ajax({
88                url: '/entity/auth/resendotp',
89                data : {
90                    name : data
91                },
92                type: 'POST',
93                success: function(response) {
94                    if(response.success)
95                    {   
96                        $('#login-otp-success-message').text("OTP sent successfully");
97                        $('#login-otp-success-message').show();
98                        $("#resend-timer-div").show();
99                        setTimeout(function() {
100                            $("#login-otp-success-message").hide();
101                        }, 10000);
102                        resendTimer();
103                    }
104                },
105                error: function(xhr, status, error) {
106                    console.log(error);
107                }
108            })
109        })
110
111        // OTP Moving Forth and Back
112        $(document).ready(function () {
113            $(".otp-input").on("input", function () {
114                const $this = $(this);
115                const value = $this.val();
116                
117                if (value.length === 1) {
118                    $this.next(".otp-input").focus();
119                }
120            });
121
122            $(".otp-input").on("keydown", function (e) {
123                const $this = $(this);
124
125                if (e.key === "Backspace" && $this.val() === "") {
126                    $this.prev(".otp-input").focus();
127                }
128
129                if (!e.key.match(/[0-9]/) && !["Backspace", "ArrowLeft", "ArrowRight", "Tab"].includes(e.ke
129y)) {
130                    e.preventDefault();
131                }
132            });
133        });
134
135        /* Login OTP Verification */
136        $("#verify-otp").on("click", function () {
137            let otp1 = $("#Otp1").val();
138            let otp2 = $("#Otp2").val();
139            let otp3 = $("#Otp3").val();
140            let otp4 = $("#Otp4").val();
141            let otp5 = $("#Otp5").val();
142            let otp6 = $("#Otp6").val();
143
144            if(otp1 != "" && otp2 != "" && otp3 != "" && otp4 != "" && otp5 != "" && otp6 != "")
145            {
146                return true;
147            }
148
149            $('#login-otp-error-message').text("Enter a valid OTP");
150            $("#login-otp-error-message").show();
151            setTimeout(function() {
152                $("#login-otp-error-message").hide();
153            }, 10000);
154            return false;
155        });
156
157        /* Forget Password OTP Verification */
158        $("#verify-change-password-otp").on("click", function () {
159            const password = document.getElementById("New_password").value;
160            const confirmPassword = document.getElementById("Confirm_new_password").value;
161
162            const isValid = validatePasswords(password, confirmPassword);
163            if (!isValid) {
164                return false;
165            }
166
167            let otp1 = $("#Otp1").val();
168            let otp2 = $("#Otp2").val();
169            let otp3 = $("#Otp3").val();
170            let otp4 = $("#Otp4").val();
171            let otp5 = $("#Otp5").val();
172            let otp6 = $("#Otp6").val();
173
174            if(otp1 != "" && otp2 != "" && otp3 != "" && otp4 != "" && otp5 != "" && otp6 != "")
175            {
176                return true;
177            }
178
179            $('#login-otp-error-message').text("Enter a valid OTP");
180            $("#login-otp-error-message").show();
181            setTimeout(function() {
182                $("#login-otp-error-message").hide();
183            }, 10000);
184            return false;
185        });
186
187        /* Hide Message After Every 10s */
188        setTimeout(function() {
189            $("#login-otp-error-message").hide();
190        }, 10000);
191        
192    }
193};

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.