src/views/check_login.js   A
last analyzed

Complexity

Total Complexity 8
Complexity/F 1.6

Size

Lines of Code 64
Function Count 5

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
c 1
b 0
f 0
nc 1
dl 0
loc 64
rs 10
wmc 8
mnd 2
bc 10
fnc 5
bpm 2
cpm 1.6
noi 1

2 Functions

Rating   Name   Duplication   Size   Complexity  
B check_login.js ➔ init_cas 0 41 2
A check_login.js ➔ setTimeout 0 6 2
1
/*
2
* @Author: jdi-juma
3
* @Date:   2017-12-09 18:36:01
4
* @Last Modified by:   jdi-juma
5
* @Last Modified time: 2017-12-09 22:14:53
6
*/
7
//check islogin
8
var check_logout_url = $("meta[name=check_logout_url]").attr('content');
9
var check_login_url = $("meta[name=check_login_url]").attr('content');
10
var auth_page 		= $("meta[name=auth_page]").attr('content');
11
12
13
var token 			= $("meta[name=_token]").attr('content');
14
var ipaddress 		= $("meta[name=ipaddress]").attr('content');
15
var logout_url 		= $("meta[name=logout_url]").attr('content');
16
var auth_check 		= $("meta[name=auth_check]").attr('content');
17
var current_url 	= $("meta[name=current_url]").attr('content');
18
19
setTimeout(function(){
20
	if(ipaddress == '')
21
	{
22
		ipaddress = $('.ip1').val()+'-'+$('.ip2').val();
23
	}
24
},500);
25
26
27
function init_cas() 
28
{
29
	if(auth_check == 1)
30
	{
31
		/*$.post(check_logout_url, 
32
		{
33
			_token 			: token,
34
			ipaddress		: ipaddress
35
		}, 
36
		function(response){
37
			if(response == 1)
38
			{
39
				// force logout
40
				$.get(logout_url, function(response){
41
					return false;
42
				});
43
			}
44
			return false;
45
		});*/
46
	}
47
	else
48
	{
49
		$.post(check_login_url, 
50
			{
51
				_token 			: token,
52
				ipaddress		: ipaddress
53
			}, 
54
			function(response){
55
				if(response == 1)
56
				{
57
					window.location.href = auth_page;
58
				}
59
				else
60
				{
61
					$.get(logout_url, function(response){
0 ignored issues
show
Unused Code introduced by
The parameter response is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
62
						return false;
63
					});
64
				}
65
			});
66
	}
67
}
68
69
setTimeout(function(){
70
	init_cas();
71
}, 1000);
72
73