Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict';
- module.exports = function CreateGroupKeyController ( $scope, $modalInstance, ToasterService, ApiService, collection ) {
- var self = this;
- var groupid, newData, key;
- self.disableGroupKeyField = false;
- self.errorDuplicategroupKey = false;
- function createUrlSuccessHandler ( urlResponse ) {
- console.log( urlResponse );
- newData.Return = urlResponse.data.DestinationUrl;
- newData.entityId = urlResponse.data.EntityId;
- newData.certificate = urlResponse.data.SigningCertificatePath;
- }
- function commonErrorHandler ( err ) {
- ToasterService.error( err.data );
- }
- function createContactSuccessHandler ( contactResponse ) {
- newData = contactResponse.data;
- newData.Key = key;
- if ( self.samlChecked ) {
- ApiService.sso.createUrl( groupid, self.groupKey.url, self.groupKey.entityId, self.groupKey.certificate ).then( createUrlSuccessHandler, commonErrorHandler );
- }
- collection.push( newData );
- $modalInstance.close();
- ToasterService.success( 'GroupKey was successfully added to a user.' );
- }
- function createGroupKeySuccessHandler ( createResponse ) {
- self.errorDuplicategroupKey = false;
- self.disableGroupKeyField = true;
- self.groupKey.secret = createResponse.data.Secret;
- groupid = createResponse.data.GroupId;
- key = createResponse.data.Key;
- ApiService.sso.createContact( groupid, self.groupKey.email ).then( createContactSuccessHandler, commonErrorHandler );
- }
- function createGroupKeyErrorHandler () {
- self.errorDuplicategroupKey = true;
- }
- function generate () {
- ApiService.sso.createGroupKey( self.groupKey.groupKey ).then( createGroupKeySuccessHandler, createGroupKeyErrorHandler );
- }
- $scope.cancel = function () {
- $modalInstance.dismiss();
- };
- $scope.ok = function () {
- generate();
- };
- self.generate = generate;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement