Subversion Repositories SmartDukaan

Rev

Rev 7039 | Rev 20203 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7039 Rev 7825
Line 27... Line 27...
27
				minlength: 6,
27
				minlength: 6,
28
				maxlength: 20
28
				maxlength: 20
29
			}
29
			}
30
		}
30
		}
31
	});
31
	});
32
});
-
 
33
32
	
-
 
33
	$('.loginregister').live('click', function(){
-
 
34
		if($('input[name=loginregister]:checked').val() == "register") {
-
 
35
			$('#signin').hide();
-
 
36
			$('#signup').show();
-
 
37
		} else {
-
 
38
			$('#signin').show();
-
 
39
			$('#signup').hide();
-
 
40
		}
-
 
41
	});
-
 
42
	
-
 
43
});
-
 
44
 
-
 
45
function loginToSaholicByFacebook(userDetails, authResponse){
-
 
46
	var longLivedToken = null;
-
 
47
	
-
 
48
	if(authResponse!==null) {
-
 
49
		$.ajax({
-
 
50
			type	: "GET",
-
 
51
			url		: "https://graph.facebook.com/oauth/access_token?grant_type=fb_exchange_token&client_id="+
-
 
52
					   '${in.shop2020.appId}' + "&client_secret="+'${in.shop2020.appSecret}'+
-
 
53
					  "&fb_exchange_token="+authResponse.accessToken,
-
 
54
	
-
 
55
			success	: function(response) {
-
 
56
				longLivedToken = response.substring(0,response.indexOf("&expires")).split("=")[1];
-
 
57
			},
-
 
58
			
-
 
59
			complete: function() {
-
 
60
				$.ajax({
-
 
61
					type : "POST",
-
 
62
					url : "/login/?email="+userDetails.email+"&name="+userDetails.name+"&gender="+userDetails.gender+"&isFacebookUser=True&accessToken="+longLivedToken+"&facebookId="+authResponse.userID,
-
 
63
					success : function(response) {
-
 
64
						window.location = "/";
-
 
65
					}
-
 
66
				});
-
 
67
			}
-
 
68
			
-
 
69
		});
-
 
70
	} else {
-
 
71
		$.ajax({
-
 
72
			type : "POST",
-
 
73
			url : "/login/?email="+userDetails.email+"&name="+userDetails.name+"&gender="+userDetails.gender+"&isFacebookUser=True",
-
 
74
			success : function(response) {
-
 
75
				window.location = "/";
-
 
76
			}
-
 
77
		});
-
 
78
	}
-
 
79
}
-
 
80
34
81