1 (function(angular
, $, _
) {
2 angular
.module('oauthUtil', CRM
.angRequires('oauthUtil'));
3 // Import data from the 'CRM.foo' settings.
4 // Ex: <div oauth-util-import="CRM.oauthUtil.providers" to="theProviders" />
5 angular
.module('oauthUtil').directive('oauthUtilImport', function() {
12 controller: function($scope
, $parse
) {
13 $scope
.to
= $parse($scope
.oauthUtilImport
)({CRM
: CRM
});
17 angular
.module('oauthUtil').directive('oauthUtilGrantCtrl', function() {
21 oauthUtilGrantCtrl
: '='
23 controllerAs
: 'oauthUtilGrantCtrl',
24 controller: function($scope
, $parse
, crmBlocker
, crmApi4
, crmStatus
) {
25 var block
= crmBlocker();
27 ctrl
.authCode = function(clientId
) {
29 message
: ts('You are about to be redirected to an external site.'),
30 options
: {no
: ts('Cancel'), yes
: ts('Continue')}
32 CRM
.confirm(confirmOpt
)
33 .on('crmConfirm:yes', function(){
34 var going
= crmApi4('OAuthClient', 'authorizationCode', {
35 'landingUrl': window
.location
.href
,
36 'where': [['id', '=', clientId
]]
38 window
.location
= r
[0].url
;
40 return block(crmStatus({start
: ts('Redirecting...'), success
: ts('Redirecting...')}, going
));
44 $scope
.oauthUtilGrantCtrl
= this;
48 })(angular
, CRM
.$, CRM
._
);