Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 62 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 62 Rev 1187
Línea 1... Línea 1...
1
<html>
1
<html>
2
    <head>
2
    <head>
3
    </head>
3
    </head>
4
    <body>
4
    <body>
-
 
5
	<input type="button" id="btnToken" value="1) Recuperar Token" />	
-
 
6
	<input type="button" id="btnCsrf" value="2) Recuperar Csrf" />
-
 
7
	<input type="button" id="btnLogin" value="3) Hacer Login" />	
-
 
8
	<input type="button" id="btnConsulta" value="2) Enviar consula" />
-
 
9
		
-
 
10
		
-
 
11
		
5
    <form name="form" id="form" method="post">
12
    <form name="form" id="form" method="post">
6
    <label for="email">Correo</label>
13
    <label for="email">Correo</label><br>
7
    <input type="text" id="email" name="email" value="santiago.olivera@leaderslinked.com" />
14
    <input  style="width: 100%"  type="text" id="email" name="email" value="santiago.olivera@leaderslinked.com" /><br>
8
    <label for="password">Clave</label>
15
    <label for="password">Clave</label><br>
9
    <input type="password" id="password" name="password" value="**9889CESAMSluz*" />
16
    <input  style="width: 100%" type="text" id="password" name="password" value="Cesa2020$" /><br>
-
 
17
    <label for="consulta">Consulta</label><br>
10
    <input type="button" id="btnEnviar" value="Enviar" />
18
    <input  style="width: 100%"  type="text" id="consulta" name="consulta" value="" /><br>
-
 
19
    </table>
-
 
20
   
-
 
21
   
Línea 11... Línea 22...
11
    
22
    
12
    </form>
23
    </form>
Línea 13... Línea 24...
13
    <div id="content" style="height: 200px; width: 100%; border: 1px black solid">
24
    <div id="content" style="height: 200px; width: 100%; border: 1px black solid">
Línea 17... Línea 28...
17
    <script src="jquery.js"></script>
28
    <script src="jquery.js"></script>
18
    <script>
29
    <script>
19
    jQuery( document ).ready(function( $ ) {
30
    jQuery( document ).ready(function( $ ) {
20
		var token = '';
31
		var token = '';
21
		var csrf = '';
32
		var csrf = '';
-
 
33
		//var server = 'http://dev-services-leaderslinked.example.com'; 
-
 
34
		var server = 'https://dev-services.leaderslinked.com';
Línea 22... Línea 35...
22
		
35
		
-
 
36
		$('#btnCsrf').click(function(e) {
-
 
37
			if(!token) {
-
 
38
				alert('No hay token');
-
 
39
				return;
-
 
40
			}
23
		$.fn.getCsrf = function() {
41
			
24
			$.ajax({
42
			$.ajax({
25
   				'dataType'  : 'json',
43
   				'dataType'  : 'json',
26
         		'accept'    : 'application/json',
44
         		'accept'    : 'application/json',
27
            	'method'    : 'get',
45
            	'method'    : 'get',
28
              	'url'       : 'https://dev-services.leaderslinked.com/csrf',
46
              	'url'       : server + '/csrf',
29
              	'headers'	: { 
47
              	'headers'	: { 
30
					'Authorization': 'Bearer ' + token,
48
					'Authorization': 'Bearer ' + token,
31
	    		}
49
	    		}
32
     		}).done(function(response) {
50
     		}).done(function(response) {
33
            	if(response.success) {
51
            	if(response.success) {
34
					csrf = response.data
52
					csrf = response.data
35
					console.log('csrf  = ' + csrf);
-
 
36
					setTimeout(() => {
-
 
37
					  $.fn.sendMessage();
53
					$('#content').html('csrf  = ' + csrf)
38
					}, 1000);
54
					
Línea 39... Línea 55...
39
				}
55
				}
40
            
56
            
41
         	}).fail(function( jqXHR, textStatus, errorThrown) {
57
         	}).fail(function( jqXHR, textStatus, errorThrown) {
42
                console.log(textStatus)
58
                console.log(textStatus)
Línea 43... Línea 59...
43
         	});
59
         	});
44
           	return false;
60
           	return false;
45
			
61
			
46
		}
62
		});
Línea 47... Línea 63...
47
		
63
		/*
48
		$.fn.sendMessage = function() {
64
		$.fn.sendMessage = function() {
49
			var url = '';
65
			var url = '';
50
			
66
			
51
			
67
			
52
			$.ajax({
68
			$.ajax({
53
   				'dataType'  : 'json',
69
   				'dataType'  : 'json',
54
         		'accept'    : 'application/json',
70
         		'accept'    : 'application/json',
55
            	'method'    : 'post',
71
            	'method'    : 'post',
56
              	'url'       : 'https://dev-services.leaderslinked.com/chat/send/4cf9fb4b-0190-4bb4-9369-15eb68e9cace',
72
              	'url'       : server + '/chat/send/4cf9fb4b-0190-4bb4-9369-15eb68e9cace',
Línea 68... Línea 84...
68
                 console.log(textStatus)
84
                 console.log(textStatus)
69
         	});
85
         	});
70
           	return false;
86
           	return false;
Línea 71... Línea 87...
71
			
87
			
72
		}
88
		}
73
		
89
	
74
		$.fn.loadMenu = function() {
90
		$.fn.loadMenu = function() {
75
			$.ajax({
91
			$.ajax({
76
   				'dataType'  : 'json',
92
   				'dataType'  : 'json',
77
         		'accept'    : 'application/json',
93
         		'accept'    : 'application/json',
78
            	'method'    : 'get',
94
            	'method'    : 'get',
79
              	'url'       : 'https://dev-services.leaderslinked.com/helpers/menu',
95
              	'url'       : server + '/helpers/menu',
80
        		'headers'	: { 
96
        		'headers'	: { 
81
					'Authorization': 'Bearer ' + token,
97
					'Authorization': 'Bearer ' + token,
82
        		}
98
        		}
83
     		}).done(function(response) {
99
     		}).done(function(response) {
Línea 84... Línea 100...
84
            	$('#content').html(JSON.stringify(response))
100
            	$('#content').html(JSON.stringify(response))
85
            
101
            
86
         	}).fail(function( jqXHR, textStatus, errorThrown) {
102
         	}).fail(function( jqXHR, textStatus, errorThrown) {
87
                console.log(textStatus)
103
                console.log(textStatus)
88
         	});
104
         	});
Línea 89... Línea 105...
89
           	return false;
105
           	return false;
-
 
106
		}*/
-
 
107
		
-
 
108
		$('#btnToken').click(function(e) {
-
 
109
			
-
 
110
			if(token) {
-
 
111
				alert('Ya existe el token');
90
		}
112
				return;
91
		
113
			}
92
		$.fn.loadToken = function() {
114
			
93
				$.ajax({
115
			$.ajax({
94
   				'dataType'  : 'json',
116
   				'dataType'  : 'json',
95
         		'accept'    : 'application/json',
117
         		'accept'    : 'application/json',
Línea 96... Línea 118...
96
            	'method'    : 'get',
118
            	'method'    : 'get',
97
              	'url'       : 'https://dev-services.leaderslinked.com/signin',
119
              	'url'       : server + '/signin',
98
     		}).done(function(response) {
120
     		}).done(function(response) {
99
            	
121
            	
Línea 100... Línea 122...
100
            	if(response.success) {
122
            	if(response.success) {
101
					token = response.data.jwt;
123
					token = response.data.jwt;
102
					console.log('token = ' + token);
124
					$('#content').html('token = ' + token)
103
				}
125
				}
-
 
126
            
104
            
127
         	}).fail(function( jqXHR, textStatus, errorThrown) {
105
         	}).fail(function( jqXHR, textStatus, errorThrown) {
128
                 console.log(textStatus)
Línea 106... Línea 129...
106
                 console.log(textStatus)
129
         	});
107
         	});
130
           	return false;
Línea 108... Línea 131...
108
           	return false;
131
		});
-
 
132
		
109
			
133
		
-
 
134
    
-
 
135
        $('#btnLogin').click(function(e) {
-
 
136
			e.preventDefault();
110
		}
137
			
111
    
138
			if(!token) {
-
 
139
				alert('No hay token');
112
        $('#btnEnviar').click(function(e) {
140
				return;
113
			e.preventDefault();
141
			}
114
			
142
			
115
			if(token) {
143
			if(!csrf) {
116
				csrf = '';
144
				alert('No hay csrf');
117
				 $.fn.getCsrf();
145
				return;
118
			} else {
146
			}
119
 
147
			
120
	         	$.ajax({
148
			$.ajax({
-
 
149
	   				'dataType'  : 'json',
121
	   				'dataType'  : 'json',
150
	         		'accept'    : 'application/json',
122
	         		'accept'    : 'application/json',
151
	            	'method'    : 'post',
123
	            	'method'    : 'post',
152
	              	'url'       : server + '/signin/debug',
124
	              	'url'       : 'https://dev-services.leaderslinked.com/signin',
-
 
125
	        		'data'      : $('#form').serialize(),
-
 
126
	        		'headers'	: { 
-
 
127
						'Authorization': 'Bearer ' + token,
-
 
Línea 128... Línea 153...
128
	        		}
153
	        		'data'      : $('#form').serialize(),
129
	     		}).done(function(response) {
154
	        		'headers'	: { 
130
	            	if(response.success) {
155
						'Authorization': 'Bearer ' + token,
131
						setTimeout(() => {
156
						'X-CSRF-TOKEN' : csrf,
132
						  $.fn.getCsrf();
157
	        		}
133
						}, 1000);
158
	     		}).done(function(response) {
Línea -... Línea 159...
-
 
159
					$('#content').html(JSON.stringify(response))
-
 
160
	            
-
 
161
	         	}).fail(function( jqXHR, textStatus, errorThrown) {
-
 
162
	                 console.log(textStatus)
-
 
163
	         	});
-
 
164
	      
-
 
165
           	return false;
-
 
166
        });
-
 
167
        
-
 
168
        $('#btnConsulta').click(function(e) {
-
 
169
			e.preventDefault();
-
 
170
			
-
 
171
			if(!token) {
-
 
172
				alert('No hay token');
-
 
173
				return;
-
 
174
			}
-
 
175
 
-
 
176
			
-
 
177
			$.ajax({
-
 
178
	   				'dataType'  : 'json',
-
 
179
	         		'accept'    : 'application/json',
-
 
180
	            	'method'    : 'get',
-
 
181
	              	'url'       : $('#consulta').val(),
-
 
182
	        		'headers'	: { 
134
					}
183
						'Authorization': 'Bearer ' + token,
-
 
184
	        		}
-
 
185
	     		}).done(function(response) {
-
 
186
					$('#content').html(JSON.stringify(response))
Línea 135... Línea 187...
135
	            
187
	            
136
	         	}).fail(function( jqXHR, textStatus, errorThrown) {
188
	         	}).fail(function( jqXHR, textStatus, errorThrown) {
137
	                 console.log(textStatus)
189
	                 console.log(textStatus)
138
	         	});
190
	         	});