PageSourceSearch

https://discovered.tv/repo/js/auth.js?q=310

js discovered.tv collected 2026-10-02 06:28:56 UTC 23,406 bytes, 659 lines download raw bytes

1
2var sigup_acc_type 	= 'standard',
3	path 			= window.location.pathname, 
4	page 			= path.split("/").pop(),
5	giveawayMess  	=  'You have participated in the giveaway successfully';
6	
7const urlParams = new URLSearchParams(window.location.search);
8const autopopup = urlParams.get('popup');
9if(autopopup == 'login'){
10	$('[data-cls="login_mdl"]').eq(1).click();
11}
12
13if(page == 'giveaways'){
14	sigup_acc_type = 'express';
15}
16
17$(function() {
18	
19	$(document).on('click','.chooseAccType',function(){
20		// sigup_acc_type = $(this).data('acctype');
21		$('.dis_signup_grid_wrap').addClass('hide');
22		$('.dis_signup_wrapper').removeClass('hide');
23		$('#signup_details').modal('hide');
24	})
25	
26	// if(typeof FB != 'undefined'){
27	function statusChangeCallback(response) {  // Called with the results from FB.getLoginStatus().
28		console.log('statusChangeCallback');
29		console.log(response);                   // The current login status of the person.
30		if(response.status === 'connected') {   // Logged into your webpage and Facebook.
31			testAPI();  
32		}else {                                 // Not logged into your webpage or we are unable to tell.
33		// document.getElementById('status').innerHTML = 'Please log ' + 'into this webpage.';
34		}
35	}
36
37	function checkLoginState(){              // Called when a person is finished with the Login Button.
38		FB.getLoginStatus(function(response) {   // See the onlogin handler
39			statusChangeCallback(response);
40		});
41	}
42
43	// window.fbAsyncInit = function() {
44    
45	// };
46	function fbinit(){
47		let myPromise = new Promise(function(myResolve, myReject){
48			FB.init({
49				// appId   : 338023836397118,
50				appId   : 1326011312245463, /* 1326011312245463 by Skeeter Marazzo Account */ /* 224158422690703 By shubam modi himanshusofttech as admin in main account*/ //788917895217611
51				status  : true,
52				xfbml   : true,
53				version : 'v4.0'
54			});	
55		  
56			(function(d, s, id) {                      // Load the SDK asynchronously
57				var js, fjs = d.getElementsByTagName(s)[0];
58				if (d.getElementById(id)) return;
59				js = d.createElement(s); js.id = id;
60				js.src = "https://connect.facebook.net/en_US/sdk.js";
61				fjs.parentNode.insertBefore(js, fjs);
62				setTimeout(function(){
63					myResolve();
64				},2000)
65			}(document, 'script', 'facebook-jssdk'));
66			
67		});
68		return myPromise;
69	}
70	
71 
72	function testAPI() {                      // Testing Graph API after login.  See statusChangeCallback() for when this call is made.
73		console.log('Welcome!  Fetching your information.... ');
74		FB.api('/me?fields=name,id,email', function(response) {
75		  console.log('Successful login for: ' + response.name);
76		  	response.provider = 'facebook';
77		  	social_login(response);
78			console.log(response);
79		});
80	}
81	
82	var fab = false;
83	
84	// Facebook SDK initialization promise
85	let fbReadyPromise;
86	function ensureFBReady() {
87	    if (!fbReadyPromise) {
88	        fbReadyPromise = new Promise(function(resolve, reject) {
89	            window.fbAsyncInit = function() {
90	                FB.init({
91	                    appId   : 1326011312245463,
92	                    status  : true,
93	                    xfbml   : true,
94	                    version : 'v4.0'
95	                });
96	                resolve();
97	            };
98	            // Load the SDK asynchronously if not already loaded
99	            if (!document.getElementById('facebook-jssdk')) {
100	                var js = document.createElement('script');
101	                js.id = 'facebook-jssdk';
102	                js.src = 'https://connect.facebook.net/en_US/sdk.js';
103	                var fjs = document.getElementsByTagName('script')[0];
104	                fjs.parentNode.insertBefore(js, fjs);
105	            }
106	        });
107	    }
108	    return fbReadyPromise;
109	}
110	
111	function fblogin() {
112	    ensureFBReady().then(function() {
113	        FB.login(statusChangeCallback, {scope: 'email,public_profile', return_scopes: true});
114	    });
115	}
116
117	$(document).on('click','#faceLogin',function(){
118		fblogin() // FB.login(statusChangeCallback, {scope: 'email,public_profile', return_scopes: true});
119	});
120
121	//if(document.getElementById("faceLogin")){
122		//document.getElementById("faceLogin").addEventListener("click", function(){
123			//fblogin() // FB.login(statusChangeCallback, {scope: 'email,public_profile', return_scopes: true});
124		//});
125	//}
126	if(document.getElementById("faceSignup")){
127		document.getElementById("faceSignup").addEventListener("click", function(){
128			fblogin() // FB.login(statusChangeCallback, {scope: 'email,public_profile', return_scopes: true});
129		});
130	}
131	// }
132	var goo = false;
133	$(document).on('click','.au_google',function(){
134		if(goo){
135			$('.abcRioButtonIcon').trigger('click');
136		}else{
137			loadScript(G_AUTH,function(){
138				setTimeout(function(){
139					$('.abcRioButtonIcon').trigger('click');	
140				},500)
141			}); 
142		}
143		
144	})
145	
146	
147	
148})
149
150	function onSignIn(googleUser) {
151		
152		var profile = googleUser.getBasicProfile();
153		console.log('ID: ' + profile.getId());
153 // Do not send to your backend! Use an ID token instead.
154		console.log('Name: ' + profile.getName());
155		console.log('Image URL: ' + profile.getImageUrl());
156		console.log('Email: ' + profile.getEmail()); // This is null if the 'email' scope is not present.
157		let response = {email:profile.getEmail(),name:profile.getName(),id:profile.getId(),provider:'google'};
158		signOut(response)
159	}
160	
161	function signOut(response) {
162		var auth2 = gapi.auth2.getAuthInstance();
163		auth2.signOut().then(function () {
164			social_login(response);
165			console.log('User signed out.');
166		});
167	}
168	
169	function social_login(response, ageConfirmed){
170
171	let formData = new FormData();
172		formData.append('user_email',response.email);
173		formData.append('user_name',response.name);
174		formData.append('user_social',response.id);
175		formData.append('social_provider',response.provider || '');
176		formData.append("sigup_acc_type", sigup_acc_type);
177		// Only used when this login creates a NEW account; the server ignores it for existing users
178		if(ageConfirmed === true || $('#age_confirm').is(':checked')){
179			formData.append("age_confirmed", 1);
180		}
181		if(page == 'giveaways'){
182			formData.append("is_giveaways",1);
183		}
184		const getdiscovered = urlParams.get('getdiscovered');
185		if(getdiscovered){
186			formData.append("registration_source",'getdiscovered');
187		}
188
189		const gamepass = urlParams.get('gamepass');
190		if(gamepass){
191			formData.append("registration_source",'gamepass');
192		}
193
194		manageMyAjaxPostRequestData(formData , base_url+'home/social_login').done(function(resp){
195			
196			resp = JSON.parse(resp);
197			console.log(resp);
198			if(resp.status == 1){
199				
200				// Opened as a popup by the embedded chat. Tell the opener and close,
201				// rather than sending a window the user never navigated to off to a
202				// profile or account type page. Same signal the email login sends.
203				if(window.CHAT_LOGIN_POPUP === true){
204
205					$('#chatLoginForm').hide();
206					$('#chatLoginDone').show();
207
208					console.log('[ChatAuth] social_login success in chat popup. window.opener present:', !!window.opener,
209						' closed:', window.opener ? window.opener.closed : 'n/a', ' target origin:', window.CHAT_LOGIN_ORIGIN);
210
211					try {
212						if(window.opener && !window.opener.closed){
213							window.opener.postMessage('DISCOVERED_LOGIN_SUCCESS', window.CHAT_LOGIN_ORIGIN);
214							console.log('[ChatAuth] postMessage sent to opener.');
215						} else {
216							console.warn('[ChatAuth] postMessage NOT sent -- window.opener is missing or already closed.');
217						}
218					} catch (e) { console.warn('[ChatAuth] postMessage threw:', e); }
219
220					setTimeout(function(){ window.close(); }, 800);
221					return;
222				}
223
224				if(resp.user != 'newLogin'){
225					let path = window.location.href;
226						path = path.replace("#", "");
227
228					let params = (new URL(path)).searchParams;
229						params = params.get('invite'); 
230					
231					if(page == 'giveaways'){
232						Custom_notify('success',giveawayMess);
233					}
234					setTimeout(function(){
235						if(	base_url 	== 	path ||  
236							path 		==  base_url+"sign-up" ||  
237							path 		==  base_url+"giveaways" ||  
238							path 		==  base_url+"home/messages/activation_success" ||
239							path 		==  base_url+"home/messages/pwd_change_success" ||
240							params 		!= 	null)
241						{	
242							//window.location = 	base_url+"profile?user="+resp.user;
243							window.location = 	base_url+"profile?user=social";
244						}else{
245							window.location =	path;
246						}
247					},1500);
248				}else{
249					window.location = 	base_url+"dashboard";
250				}
251			}else
252			if(resp.status == 2){
253				Custom_notify('error',resp.message);
254
255				setTimeout(function(){
256					window.location = 	base_url+'sign-up';
257				},5000);
258			}else
259			if(resp.status == 3){
260				// New social account: the server refused to create it until 16+ is confirmed
261				showAgeConfirmPrompt(response);
262			}
263			else{
264				setTimeout(function(){
265					// window.location.href = base_url+'home/logout';
266				},3000);
267			}
268		})
269	}
270	/* Age gate: ask a NEW Google/Facebook user to confirm 16+ before the account is created.
271	   Shown on top of any page (login popup, chat login, giveaways) so it does not depend
272	   on a Bootstrap modal being available or stacking over the login modal. */
273	function showAgeConfirmPrompt(response){
274		$('#ageConfirmOverlay').remove();
275
276		let html = '<div id="ageConfirmOverlay" style="position:fixed;top:0;left:0;right:0;bottom:0;z-index:20000;background:rgba(0,0,0,0.6);display:flex;align-items:center;justify-content:center;padding:16px;">'
277				+ '<div class="modal-content" style="max-width:420px;width:100%;padding:24px;">'
278					+ '<h4 class="text-center">One more step</h4>'
279					+ '<p>You are creating a new account.</p>'
280					+ '<label for="age_confirm_prompt" style="display:flex;align-items:center;gap:10px;cursor:pointer;margin:8px 0 0;">'
281						+ '<input type="checkbox" id="age_confirm_prompt" style="margin:0;width:18px;height:18px;flex:0 0 auto;">'
282						+ '<span>I confirm that I am at least 16 years old.</span>'
283					+ '</label>'
284					+ '<span class="form-error help-block" id="age_confirm_prompt_error" style="color:#eb581f;"></span>'
285					+ '<p><small>By creating an account, you represent that you are at least 16 years of age and agree to our <a target="_blank" href="'+base_url+'terms-and-privacy">Terms of Use</a> and <a target="_blank" href="'+base_url+'policies">Privacy Policy</a>.</small></p>'
286					+ '<div class="text-center" style="display:flex;gap:10px;justify-content:center;">'
287						+ '<button type="button" class="dis_btn" id="age_confirm_continue" style="flex:1;min-width:0;width:auto;margin:0;">Continue</button>'
288						+ '<button type="button" class="dis_btn" id="age_confirm_cancel" style="flex:1;min-width:0;width:auto;margin:0;">Cancel</button>'
289					+ '</div>'
290				+ '</div>'
291			+ '</div>';
292
293		$('body').append(html);
294
295		$('#age_confirm_continue').on('click',function(){
296			if(!$('#age_confirm_prompt').is(':checked')){
297				$('#age_confirm_prompt_error').text('Please confirm that you are at least 16 years old.');
298				return false;
299			}
300			$('#ageConfirmOverlay').remove();
301			social_login(response, true);
302		});
303
304		$('#age_confirm_cancel').on('click',function(){
305			$('#ageConfirmOverlay').remove();
306		});
307	}
308
309	/* Validate Login Page STARTS*/
310
311	$('.login_form').on('keyup',function(event){
312		event.preventDefault();
313		if(event.keyCode == 13){
314			login_user();
315		}
316	});
317
318	// Gamification - cookie functions
319	function getCookie(name) {
320		const value = `; ${document.cookie}`;
321		const parts = value.split(`; ${name}=`);
322		if (parts.length === 2) return parts.pop().split(';').shift();
323	}
324
325	function setCookie(name, value, expirationDays = 365) {
326		const date = new Date();
327		date.setTime(date.getTime() + (expirationDays * 24 * 60 * 60 * 1000));
328		const expires = `expires=${date.toUTCString()}`;
329		document.cookie = `${name}=${value};${expires};path=/`;
330	}
331
332	
333	function login_user(){
334		var u_em = $.trim($('#u_email').val());
335		var u_pwd = $.trim($('#u_pwd').val());
336		var recaptcha_response  = $.trim(getRecaptchaResponse('login-recaptcha'));
337		
338		$('#u_email').next().text('');
339		$('#u_pwd').next().text('');
340		
341		$('.login_form').removeClass('error');
342		$('.login_form').next().text('');
343		
344			if(u_em != '' ){
345				if( u_pwd != '' ){
346					
347					var emRegex = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,15}(?:\.[a-z]{2})?)$/i;
348
349					if(!emRegex.test(u_em)) {
350						$('#u_email').addClass('error');
351						$('#u_email').next().text('Please enter a valid email address.');
352					}else if(recaptcha_response === ""){
353						$('#u_pwd').addClass('error');
354						$('#u_pwd').next().text('Please complete the reCAPTCHA.');
355						return false;
356					}else {
357						// Gamification - cookie
358						setCookie('GAM_login_user', true);
359
360						var rem_me = $('#rem_me:checked').length;
361						
362						$('.dis_btn').html('Please Wait  <i class="fa fa-spinner fa-spin post_spinner"></i>').prop('disabled', true);
363
364						grecaptcha.reset();
365						
366						let formData = new FormData(); 
367							
368							formData.append('u_em',u_em)
369							formData.append('u_pwd',u_pwd)
370							formData.append('rem_me',rem_me)
371							formData.append("g-recaptcha-response", recaptcha_response);
372							if(page == 'giveaways'){
373								if(!$('#checkBx1').is(":checked")){
374									$('.dis_btn').text('Submit').prop('disabled', false);
375									 $('#checkEr1').text('Click here to accept Giveaway\'s terms and conditions.');
376									 return false;
377								}else{
378									 $('#checkEr1').text('');
379								}
380								formData.append("is_giveaways",1);
381							}
382							manageMyAjaxPostRequestData(formData , base_url+ 'home/allow_login_access').done(function(resp){
383									
384								resp = JSON.parse(resp);
385								$('.dis_btn').text('Submit').prop('disabled', false);
386
387								if(resp.status == 1){
388
389									// Opened as a popup by the embedded chat. Tell the opener and
390									// close, rather than redirecting a window the user never
391									// navigated to. Only a plain success word is sent -- no token,
392									// no credentials -- and only to this site's own origin.
393									if(window.CHAT_LOGIN_POPUP === true){
394
395										$('#chatLoginForm').hide();
396										$('#chatLoginDone').show();
397
398										console.log('[ChatAuth] email login success in chat popup. window.opener present:', !!window.opener,
399											' closed:', window.opener ? window.opener.closed : 'n/a', ' target origin:', window.CHAT_LOGIN_ORIGIN);
400
401										try {
402											if(window.opener && !window.opener.closed){
403												window.opener.postMessage('DISCOVERED_LOGIN_SUCCESS', window.CHAT_LOGIN_ORIGIN);
404												console.log('[ChatAuth] postMessage sent to opener.');
405											} else {
406												console.warn('[ChatAuth] postMessage NOT sent -- window.opener is missing or already closed.');
407											}
408										} catch (e) { console.warn('[ChatAuth] postMessage threw:', e); }
409
410										setTimeout(function(){ window.close(); }, 800);
411										return;
412									}
413
414									$('#myModal').modal('hide');
415									
416									let path = window.location.href;
417								
418									let params = (new URL(path)).searchParams;
419										params = params.get('invite'); 
420									
421									if(page == 'giveaways'){
422										Custom_notify('success',giveawayMess);
423									}
424									setTimeout(function(){
425										if(	base_url 	== 	path.replace("#", "") ||  
426											path 		==  base_url+"sign-up" ||  
427											path 		==  base_url+"giveaways" ||  
428											path 		==  base_url+"home/messages/activation_success" ||
429											path 		==  base_url+"home/messages/pwd_change_success" ||
430											params 		!= 	null)
431										{
432													
433											//window.location = 	base_url+"profile?user="+resp.user;
434											window.location = 	base_url+"profile?user=social";
435										}else{
436											window.location =	path;
437										}
438									},1500);
439								}else{
440									$('#u_pwd').addClass('error');
441									$('#u_pwd').next().html(resp.mess);
442								}
443
444							});
445						}
446					}
447					else {
448						
449						$('#u_pwd').addClass('error');
450						$('#u_pwd').next().text('Please enter your password.');
451					}
452			}
453			else {
454				$('#u_email').addClass('error');
455				$('#u_email').next().text('Please enter your email.');
456			}
457		
458	}
459	
460	
461	$(document).on('keyup','.reg_form',function(e){
462		e.preventDefault();
463		if (e.keyCode == 13) {
464			register_user();
465		}
466	})
467	
468	function register_user() {
469		var u_em = $.trim($("#user_email").val());
470		var u_pwd = $.trim($("#user_pwd").val());
471		var user_name = $.trim($('#user_name').val());
472		var recaptcha_response  = $.trim(getRecaptchaResponse('signup-recaptcha'));
473		
474		$(".reg_form").removeClass("error").next().next().text("");
475		$("#user_email_error").text("");
476		$("#user_pwd_error").text("");
477		$("#user_name_error").text("");
478		$("#age_confirm_error").text("");
479		$("#message").text("");
480
481		if( user_name != '' ){
482			if (u_em != "") {
483				if (u_pwd != "") {
484					var emRegex = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,15}(?:\.[a-z]{2})?)$/i;
485					var PwRegex = /^(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[#?!@$%^&*-]).{8,}$/;
486					if (!emRegex.test(u_em)) {
487						$("#user_email").addClass("error");
488
489						$("#user_email_error").text(
490							"Please enter a valid email address."
491						);
492					} else if (!PwRegex.test(u_pwd)) {
493						$("#user_pwd").addClass("error");
494						$("#user_pwd_error").text(
495							"Invalid password, please make sure the password is atleast 8 characters with one number, one capatalized letter and one special character."
496						);
497					}else if(!$('#age_confirm').is(':checked')){
498						$('#age_confirm_error').text('Please confirm that you are at least 16 years old.');
499						return false;
500					}else if(recaptcha_response === ""){
501						$("#user_pwd").addClass("error");
502						$("#message").text('Please complete the reCAPTCHA.');
503						return false;
504					}else {
505						$(".sign_btn")
506							.text("Processing ")
507							.append(
508								'<i class="fa fa-spinner fa-spin post_spinner" ></i>'
509							)
510							.prop("disabled", true);
511							
512						grecaptcha.reset();
513
514						let formData = new FormData();
515						formData.append("u_em", u_em);
516						formData.append("u_pwd", u_pwd);
517						formData.append("user_name", user_name);
518						formData.append("sigup_acc_type", sigup_acc_type);
519						formData.append("age_confirmed", 1);
520						formData.append("g-recaptcha-response", recaptcha_response);
521						
522						if(page == 'giveaways'){ 
523							if(!$('#checkBx2').is(":checked")){
524								$(".sign_btn").text("SIGN UP").prop("disabled", false);
525								$('#checkEr2').text('Click here to accept Giveaway\'s terms and conditions.');
526								return false;
527							}else{
528								$('#checkEr2').text('');
529							}
530							formData.append("is_giveaways",1);
531						}
532						
533						const getdiscovered = urlParams.get('getdiscovered');
534						if(getdiscovered){
535							formData.append("registration_source",'getdiscovered');
536						}
537						let success_message = "We have sent an email with activation link. Click on that link to activate your account. If you don’t see the email, you may need to check your SPAM/ JUNK folder.";
538						const gamepass = urlParams.get('gamepass');
539						if(gamepass){
540							success_message = "You will receive your Game Pass coupon code via email within 24 hours of completing your signup. we have sent an email with activation link. Click on that link to activate your account. If you don’t see the email, you may need to check your SPAM/ JUNK folder.";
541							formData.append("registration_source",'gamepass');
542						}
543
544						manageMyAjaxPostRequestData(
545							formData,
546							base_url + "home/register_email"
547						).done(function (data) {
548							$(".sign_btn").text("SIGN UP").prop("disabled", false);
549							if (data == 404) {
550								$("#user_pwd").addClass("error");
551								$("#message").text("Server error.");
552								setInterval(function () {
553									window.location.reload(1);
554								}, 2000);
555							} else if (data == 401) {
556								$("#user_pwd").addClass("error");
557								$("#message")
558									.text(
559										"This email is already registered. Please enter a different email ID."
560									)
561									.css("color", "#eb581f");
562							}else if (data == 1){
563								$("#user_pwd")
564									.next()
565									.attr("style", "color:green !important;");
566								$("#message")
567									.text(success_message)
568									.css("color", "green").css("margin-bottom", "10px");
569								if(page == 'giveaways'){
570									Custom_notify('success',giveawayMess);
571								}
572								setInterval(function () {
573									window.location.reload(1);
574								}, 50000);
575							}else{
576								$("#user_pwd").addClass("error");
577								$("#message").text(data);
578							}
579						});
580					}
581				} else {
582					$("#user_pwd").addClass("error");
583					$("#user_pwd_error").text("Please enter your password.");
584				}
585			} else {
586				$("#user_email").addClass("error");
587				$("#user_email_error").text("Please enter your email.");
588			}
589		}
590		else {
591			$('#user_name').addClass('error');
592			$('#user_name_error').text('Please enter your name.');
593		}
594	}
595	
596	$(document).on("keypress", "#user_pwd", function () {
597		$("#user_pwd_error").text("");
598	});
599	
600	$(document).on('click','#resend_verify_email',function(e){
601		e.preventDefault();
602		resend_verification_mail();
603	})
604
605	function resend_verification_mail(){
606		var u_em = $.trim($('#u_email').val());
607		var u_pwd = $.trim($('#u_pwd').val());
608		
609		let btn_text = $('#resend_verify_email').text();
610		if(u_em != '' ){
611			if( u_pwd != '' ){
612				
613				var emRegex = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,15}(?:\.[a-z]{2})?)$/i;
614
615				if(!emRegex.test(u_em)) {
616					$('#u_email').addClass('error');
617					$('#u_email').next().text('Please enter a valid email address.');
618				}else {
619					
620						$('#resend_verify_email').html('Please Wait  <i class="fa fa-spinner fa-spin post_spinner"></i>').prop('disabled', true);
621					
622						let formData = new FormData(); 
623						
624						formData.append('u_em',u_em)
625						formData.append('u_pwd',u_pwd)
626						
627						manageMyAjaxPostRequestData(formData , base_url+ 'home/resend_verification_mail').done(function(resp){
628								
629							resp = JSON.parse(resp);
630							$('.resend_verify_email').text(btn_text).prop('disabled', false);
631
632							if(resp.status == 1){
633								$("#u_pwd").next().attr("style", "color:green !important;");
634								$('#u_pwd').next().text(resp.mess);
635								let path = window.location.href;
636							
637								setTimeout(function(){
638									window.location =	path;
639								},3000);
640							}else{
641								$('#u_pwd').addClass('error');
642								$('#u_pwd').next().text(resp.mess);
643							}
644
645						});
646					}
647			}
648			else {
649				
650				$('#u_pwd').addClass('error');
651				$('#u_pwd').next().text('Please enter your password.');
652			}
653		}
654		else {
655			$('#u_email').addClass('error');
656			$('#u_email').next().text('Please enter your email.');
657		}
658	}
659	

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.