define(['auth/module'], function (module) {

    "use strict";

    return module.registerDirective('googleSignin', function ($rootScope, GooglePlus) {
        return {
            restrict: 'E',
            template: '<a class="g-signin btn btn-block btn-social btn-google-plus"><i class="fa fa-google-plus"></i> Sign in with Google</a>',
            replace: true,
            link: function (scope, element) {
                element.on('click', function(){
                    GooglePlus.login().then(function (authResult) {
                        $rootScope.$broadcast('event:google-plus-signin-success', authResult);

                    }, function (err) {
                        $rootScope.$broadcast('event:google-plus-signin-failure', err);

                    });
                })
            }
        };
    });
});
