Subversion Repositories SmartDukaan

Rev

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

Rev 33061 Rev 33085
Line 24... Line 24...
24
		$('#forget-password').toggle();
24
		$('#forget-password').toggle();
25
	});
25
	});
26
});
26
});
27
$(document).ajaxComplete(function() {
27
$(document).ajaxComplete(function() {
28
});
28
});
29
var startApp = function() {
-
 
30
	gapi.load('auth2', function() {
-
 
31
		// Retrieve the singleton for the GoogleAuth library and set up the
-
 
32
		// client.
-
 
33
		auth2 = gapi.auth2.init({
-
 
34
			client_id : googleApiKey,
-
 
35
			cookiepolicy : 'single_host_origin',
-
 
36
		// Request scopes in addition to 'profile' and 'email'
-
 
37
		// scope: 'additional_scope'
-
 
38
		});
-
 
39
		attachSignin(document.getElementById('customBtn'));
-
 
40
	});
-
 
41
};
-
 
42
 
29
 
43
function login() {
30
function login() {
44
	console.log("Login DashBoard");
31
	console.log("Login DashBoard");
45
	var emailIdOrMobileNumber = $("#emailormobile").val();
32
	var emailIdOrMobileNumber = $("#emailormobile").val();
46
	console.log(emailormobile);
33
	console.log(emailormobile);
Line 55... Line 42...
55
		return;
42
		return;
56
	}
43
	}
57
	submitUser(null, emailIdOrMobileNumber, password)
44
	submitUser(null, emailIdOrMobileNumber, password)
58
}
45
}
59
 
46
 
60
function attachSignin(element) {
-
 
61
	console.log(element.id);
-
 
62
	auth2.attachClickHandler(element, {}, function(googleUser) {
-
 
63
		googleProfile = googleUser.getBasicProfile();
-
 
64
		console.log(googleProfile.getImageUrl());
-
 
65
		submitUser(googleUser, googleProfile.getEmail(),null);
-
 
66
	}, function(error) {
-
 
67
		console.log(JSON.stringify(error, undefined, 2));
-
 
68
	});
-
 
69
}
-
 
70
 
-
 
71
function onSignIn(googleUser) {
47
function onSignIn(googleUser) {
72
	var profile = googleUser.getBasicProfile();
48
	var profile = googleUser.getBasicProfile();
73
	submitUser(googleUser, profile.getEmail(), null);
49
	submitUser(googleUser, profile.getEmail(), null);
74
}
50
}
75
 
51
 
-
 
52
function onLoad() {
-
 
53
	gapi.load('auth2', function () {
-
 
54
		gapi.auth2.init();
-
 
55
	});
-
 
56
}
-
 
57
 
-
 
58
// Function to handle sign-out
-
 
59
function signOut() {
-
 
60
	var auth2 = gapi.auth2.getAuthInstance();
-
 
61
	auth2.signOut().then(function () {
-
 
62
		console.log('User signed out.');
-
 
63
		// Add your custom logic for sign-out here
-
 
64
	});
-
 
65
}
-
 
66
 
-
 
67
// Function to toggle between sign-in and sign-out
-
 
68
function toggleSignInSignOut() {
-
 
69
	var auth2 = gapi.auth2.getAuthInstance();
-
 
70
	if (auth2.isSignedIn.get()) {
-
 
71
		// User is signed in, sign them out
-
 
72
		signOut();
-
 
73
	} else {
-
 
74
		// User is not signed in, initiate sign-in
-
 
75
		auth2.signIn().then(onSignIn);
-
 
76
	}
-
 
77
}
-
 
78
 
76
function submitUser(googleUser, emailIdOrMobileNumber, password) {
79
function submitUser(googleUser, emailIdOrMobileNumber, password) {
77
 
80
 
78
	if (googleUser) {
81
	if (googleUser) {
79
		var params = {
82
		var params = {
80
			"token" : googleUser.getAuthResponse().id_token,
83
			"token" : googleUser.getAuthResponse().id_token,