FS-8183 #resolve #comment add google api logins to Verto Communicator

This commit is contained in:
Ken Rice 2015-09-14 22:55:53 -05:00
parent c9bb3a2a3e
commit ab4d024bc3
6 changed files with 58 additions and 6 deletions

View File

@ -32,6 +32,7 @@
"angular-prompt": "~1.1.1",
"angular-animate": "~1.3.15",
"angular-cookies": "~1.3.15",
"angular-directive.g-signin": "~0.1.2",
"jquery": "~2.1.4",
"angular-fullscreen": "~1.0.1",
"ngstorage": "~0.3.9",

View File

@ -71,6 +71,7 @@
<script src="bower_components/angular-prompt/dist/angular-prompt.js"></script>
<script src="bower_components/angular-animate/angular-animate.js"></script>
<script src="bower_components/angular-cookies/angular-cookies.js"></script>
<script src="bower_components/angular-directive.g-signin/google-plus-signin.js"></script>
<script src="bower_components/angular-fullscreen/src/angular-fullscreen.js"></script>
<script src="bower_components/ngstorage/ngStorage.js"></script>
<script src="bower_components/momentjs/moment.js"></script>
@ -121,9 +122,9 @@
<script type="text/javascript" src="src/storageService/storageService.module.js"></script>
<script type="text/javascript" src="src/storageService/services/storage.js"></script>
<script type="text/javascript" src="src/storageService/services/call_history.js"></script>
<!-- endbuild -->
</body>
</html>

View File

@ -4,6 +4,7 @@
<div class="panel-body">
<h3>Login</h3>
<div ng-show="form.$submitted && form.$invalid" class="alert alert-danger">
<p>Verify the fields bellow and try again.</p>
</div>
@ -45,9 +46,14 @@
<input type="text" class="form-control" id="login-password" placeholder="Password" ng-model="verto.data.password">
</div>
<div class="form-group text-right">
<a style="margin-top: 13px;" href="" ng-click="advanced = !advanced" class="pull-left">Settings</a>
<button type="submit" class="btn btn-success" ng-click="(form.$valid && login())">Login</button>
<div class="form-group text-right">
<div><a style="margin-top: 13px;" href="" ng-click="advanced = !advanced" class="pull-left">Settings</a></div>
<div><button type="submit" class="btn btn-success" ng-click="(form.$valid && login())">Login</button></div>
<div ng-if="googlelogin" class="centered-block">
<google-plus-signin clientid="675954646436-cuejgg314a32s2c76dnc2n7ier3kbudu.apps.googleusercontent.com" class="center">
</google-plus-signin>
</div>
</div>
</form>
</div>

View File

@ -13,6 +13,7 @@
'cgPrompt',
'720kb.tooltips',
'ui.gravatar',
'directive.g+signin',
]);
vertoApp.config(['$routeProvider', 'gravatarServiceProvider',
@ -95,4 +96,4 @@
}
]);
})();
})();

View File

@ -3,7 +3,7 @@
angular
.module('vertoControllers')
.controller('LoginController', ['$scope', '$http', '$location', 'verto',
.controller('LoginController', ['$scope', '$http', '$location', 'verto',
function($scope, $http, $location, verto) {
$scope.checkBrowser();
@ -19,6 +19,11 @@
var name = verto.data.name;
var email = verto.data.email;
console.debug("googlelogin: " + data.googlelogin);
if (data.googlelogin){
$scope.googlelogin = data.googlelogin;
}
angular.extend(verto.data, data);
/**

View File

@ -88,6 +88,10 @@
var disconnectCallback = function(v, connected) {
console.debug('Redirecting to login page.');
storage.reset();
if (typeof gapi !== 'undefined'){
console.debug(gapi);
gapi.auth.signOut();
}
$location.path('/login');
};
@ -277,6 +281,40 @@
});
$scope.$on('event:google-plus-signin-success', function (event,authResult) {
// Send login to server or save into cookie
console.log('Google+ Login Success');
console.log(authResult);
gapi.client.load('plus', 'v1', gapiClientLoaded);
});
function gapiClientLoaded() {
gapi.client.plus.people.get({userId: 'me'}).execute(handleEmailResponse);
}
function handleEmailResponse(resp){
var primaryEmail;
for (var i=0; i < resp.emails.length; i++) {
if (resp.emails[i].type === 'account') primaryEmail = resp.emails[i].value;
}
console.debug("Primary Email: " + primaryEmail );
console.debug("display name: " + resp.displayName);
console.debug("imageurl: " + resp.image.url);
console.debug(resp);
console.debug(verto.data);
verto.data.email = primaryEmail;
verto.data.name = resp.displayName;
storage.data.name = verto.data.name;
storage.data.email = verto.data.email;
$scope.login();
}
$scope.$on('event:google-plus-signin-failure', function (event,authResult) {
// Auth failure or signout detected
console.log('Google+ Login Failure');
});
$rootScope.callActive = function(data) {
verto.data.mutedMic = storage.data.mutedMic;
verto.data.mutedVideo = storage.data.mutedVideo;